[gtk/wip/chergert/macos-iosurface] clear things as we go



commit 02a5f49edf933b28700ebfe416410a757e23c5c8
Author: Christian Hergert <christian hergert me>
Date:   Fri Feb 11 05:04:09 2022 -0800

    clear things as we go

 gdk/macos/gdkmacosglcontext.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index ca939c598c..47331a70e9 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -216,7 +216,8 @@ create_texture (CGLContextObj cgl_context,
       !CHECK_GL (NULL, glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)) ||
       !CHECK_GL (NULL, glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)) ||
       !CHECK_GL (NULL, glTexParameteri (target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE)) ||
-      !CHECK_GL (NULL, glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)))
+      !CHECK_GL (NULL, glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)) ||
+      !CHECK_GL (NULL, glBindTexture (target, 0)))
     {
       glDeleteTextures (1, &texture);
       return 0;
@@ -275,6 +276,9 @@ gdk_macos_gl_context_allocate (GdkMacosGLContext *self)
           return;
         }
 
+      glBindFramebuffer (GL_FRAMEBUFFER, 0);
+      glBindTexture (self->target, 0);
+
       self->texture = texture;
       self->fbo = fbo;
     }
@@ -287,6 +291,7 @@ gdk_macos_gl_context_release (GdkMacosGLContext *self)
   g_assert (self->texture != 0 || self->fbo == 0);
   g_assert (self->fbo != 0 || self->texture == 0);
 
+  glBindFramebuffer (GL_FRAMEBUFFER, 0);
   glActiveTexture (GL_TEXTURE0);
   glBindTexture (self->target, 0);
 
@@ -469,6 +474,7 @@ gdk_macos_gl_context_end_frame (GdkDrawContext *context,
   GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->end_frame (context, painted);
 
   surface = gdk_draw_context_get_surface (context);
+  gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
 
   /* Coordinates are in display coordinates, where as flush_rect is
   * in GDK coordinates. Must flip Y to match display coordinates where
@@ -481,12 +487,10 @@ gdk_macos_gl_context_end_frame (GdkDrawContext *context,
   swapRect[3] = flush_rect.height;              /* height */
   CGLSetParameter (self->cgl_context, kCGLCPSwapRectangle, swapRect);
 
-  glBindFramebuffer (GL_FRAMEBUFFER, 0);
+  gdk_macos_gl_context_release (self);
 
   glFlush ();
 
-  gdk_macos_gl_context_release (self);
-
   _gdk_macos_surface_swap_buffers (GDK_MACOS_SURFACE (surface), painted);
 
   [CATransaction commit];


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