[gtk/wip/chergert/gdk-macos-gl-renderer: 25/26] macos: restore GL context after realize




commit a9340e8998c3c4518912c0cd775672d3447e07a3
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 28 16:32:20 2020 -0700

    macos: restore GL context after realize

 gdk/macos/gdkmacosglcontext.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index e3741f5d17..9a42d9511a 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -160,6 +160,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext  *context,
   NSOpenGLPixelFormat *pixelFormat;
   GdkGLContext *shared;
   GdkGLContext *shared_data;
+  GdkGLContext *existing;
   GLint sync_to_framerate = 1;
   GLint opaque = 0;
   GLint validate = 0;
@@ -170,6 +171,8 @@ gdk_macos_gl_context_real_realize (GdkGLContext  *context,
   if (self->gl_context != nil)
     return TRUE;
 
+  existing = gdk_gl_context_get_current ();
+
   gdk_gl_context_get_required_version (context, &major, &minor);
 
   surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
@@ -236,7 +239,6 @@ gdk_macos_gl_context_real_realize (GdkGLContext  *context,
     }
 
   [gl_context makeCurrentContext];
-
   GLint renderer_id = 0;
   [gl_context getValues:&renderer_id forParameter:NSOpenGLContextParameterCurrentRendererID];
   GDK_DISPLAY_NOTE (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)),
@@ -244,9 +246,13 @@ gdk_macos_gl_context_real_realize (GdkGLContext  *context,
                     g_message ("Created NSOpenGLContext[%p] using %s",
                                gl_context,
                                get_renderer_name (renderer_id)));
+  [NSOpenGLContext clearCurrentContext];
 
   self->gl_context = g_steal_pointer (&gl_context);
 
+  if (existing != NULL)
+    [GDK_MACOS_GL_CONTEXT (existing)->gl_context makeCurrentContext];
+
   return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]