]> git.tdb.fi Git - libs/gl.git/commitdiff
Ensure that creating the system framebuffer doesn't change the binding
authorMikko Rasa <tdb@tdb.fi>
Tue, 9 Nov 2021 23:52:27 +0000 (01:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 10 Nov 2021 01:18:24 +0000 (03:18 +0200)
Just in case it's for some reason created at an odd time.

source/backends/opengl/systemframebuffer.cpp

index dbfe0b823b77f3333ef9bef0f36d2f421a86947a..2d0664527f734458422660be2202f85185526c54 100644 (file)
@@ -12,6 +12,11 @@ OpenGLSystemFramebuffer::OpenGLSystemFramebuffer():
 
        if(EXT_framebuffer_object)
        {
+               int old_id;
+               glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &old_id);
+               if(old_id)
+                       glBindFramebuffer(GL_DRAW_FRAMEBUFFER_BINDING, 0);
+
                int value;
                glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
                if(value==GL_NONE)
@@ -26,6 +31,9 @@ OpenGLSystemFramebuffer::OpenGLSystemFramebuffer():
                glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
                if(value!=GL_NONE)
                        sys_format = (sys_format, STENCIL_ATTACHMENT);
+
+               if(old_id)
+                       glBindFramebuffer(GL_DRAW_FRAMEBUFFER_BINDING, old_id);
        }
        else
                // Make a guess if we can't query the format