[gtk+/wip/otte/gl-drawing: 10/15] gsk: Allow 0 for gsk_gl_driver_begin_frame()



commit 3a0d1a345ad5e14b5ca6d9a96217ed7b3c3cc050
Author: Benjamin Otte <otte redhat com>
Date:   Wed Nov 23 01:03:59 2016 +0100

    gsk: Allow 0 for gsk_gl_driver_begin_frame()
    
    Special-case this situation to unset the current framebuffer and render
    to the backbuffer again.

 gsk/gskgldriver.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gsk/gskgldriver.c b/gsk/gskgldriver.c
index 4bcc376..f08b1f9 100644
--- a/gsk/gskgldriver.c
+++ b/gsk/gskgldriver.c
@@ -219,7 +219,7 @@ gsk_gl_driver_begin_frame (GskGLDriver *driver)
       GSK_NOTE (OPENGL, g_print ("GL max texture size: %d\n", driver->max_texture_size));
     }
 
-  glGetIntegerv (GL_FRAMEBUFFER_BINDING, (GLint *) &(driver->default_fbo.fbo_id));
+  glBindFramebuffer (GL_FRAMEBUFFER, 0);
   driver->bound_fbo = &driver->default_fbo;
 
   glActiveTexture (GL_TEXTURE0);
@@ -249,6 +249,8 @@ gsk_gl_driver_end_frame (GskGLDriver *driver)
   driver->bound_vao = NULL;
   driver->bound_fbo = NULL;
 
+  driver->default_fbo.fbo_id = 0;
+
   GSK_NOTE (OPENGL,
             g_print ("*** Frame end: textures=%d, vaos=%d\n",
                      g_hash_table_size (driver->textures),
@@ -733,6 +735,13 @@ gsk_gl_driver_bind_render_target (GskGLDriver *driver,
   g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), FALSE);
   g_return_val_if_fail (driver->in_frame, FALSE);
 
+  if (texture_id == 0)
+    {
+      glBindFramebuffer (GL_FRAMEBUFFER, 0);
+      driver->bound_fbo = &driver->default_fbo;
+      goto out;
+    }
+
   f = gsk_gl_driver_get_fbo (driver, texture_id);
   if (f == NULL)
     {
@@ -747,6 +756,7 @@ gsk_gl_driver_bind_render_target (GskGLDriver *driver,
       driver->bound_fbo = f;
     }
 
+out:
   status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
 
   return status == GL_FRAMEBUFFER_COMPLETE;


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