From 4b484557f5ce0e965f7edfac26b0178a3b5c1779 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 23 Nov 2016 01:03:59 +0100 Subject: [PATCH] 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 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gsk/gskgldriver.c b/gsk/gskgldriver.c index 4bcc376084..f08b1f925a 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;