Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
demo_inprocess_egl.cpp: A simple use of egl in process

main()

The main() function uses a default configuration for Mir and sets up an InprocessEGLClient that accesses the graphics platform and surface factory.

This InprocessEGLClient sets up a single surface

auto params = msh::a_surface().of_name("Inprocess EGL Demo")
.of_size(surface_size)
.of_buffer_usage(mg::BufferUsage::hardware)
.of_pixel_format(geom::PixelFormat::argb_8888);
auto session = session_manager->open_session("Inprocess client",
std::make_shared<NullEventSink>());
// TODO: Why do we get an ID? ~racarr
auto surface = session->get_surface(session_manager->create_surface_for(session, params));
auto input_platform = mircv::InputPlatform::create();
input_thread = input_platform->create_input_thread(
surface->client_input_fd(),
std::bind(std::mem_fn(&me::InprocessEGLClient::handle_event), this, std::placeholders::_1));
input_thread->start();
auto internal_client = graphics_platform->create_internal_client();
auto internal_surface = as_internal_surface(surface);
me::EGLHelper helper(internal_client->egl_native_display(), internal_client->egl_native_window(internal_surface));
auto rc = eglMakeCurrent(helper.the_display(), helper.the_surface(), helper.the_surface(), helper.the_context());
assert(rc == EGL_TRUE);
gl_animation.init_gl();

And loops updating the surface

while(!terminate)
{
gl_animation.render_gl();
rc = eglSwapBuffers(helper.the_display(), helper.the_surface());
assert(rc == EGL_TRUE);
gl_animation.step();
}
(void)rc;
input_thread->stop();

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013