Get currently bound GL context when creating new GL context and restore it after the creation for consistency. In particular, if there was no GL context bound when gd_gl_area_create_context() invoked, then GL context will be unbound, which is important GL housekeeping detail because GL may be performed by different QEMU process threads.
Signed-off-by: Dmitry Osipenko <[email protected]> --- ui/gtk-gl-area.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index cd86022d264a..fb783db3042d 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -251,11 +251,13 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { VirtualConsole *vc = container_of(dgc, VirtualConsole, gfx.dgc); + GdkGLContext *ctx, *current_ctx; GdkWindow *window; - GdkGLContext *ctx; GError *err = NULL; int major, minor; + current_ctx = gdk_gl_context_get_current(); + window = gtk_widget_get_window(vc->gfx.drawing_area); ctx = gdk_window_create_gl_context(window, &err); if (err) { @@ -284,6 +286,12 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc, g_clear_object(&ctx); } + if (current_ctx) { + gdk_gl_context_make_current(current_ctx); + } else { + gdk_gl_context_clear_current(); + } + trace_gd_gl_area_create_context(ctx, params->major_ver, params->minor_ver); return ctx; } -- 2.52.0
