]> git.tdb.fi Git - libs/gl.git/commitdiff
Prefer glDrawBuffers over glDrawBuffer
authorMikko Rasa <tdb@tdb.fi>
Fri, 17 Oct 2014 20:09:44 +0000 (23:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 17 Oct 2014 20:09:44 +0000 (23:09 +0300)
OpenGL ES does not have glDrawBuffer, so this logic change makes porting
a bit easier.

source/framebuffer.cpp

index 8c618ce51b7112ba96f4332cb1e08de683744397..f4e5a9445e0bce678292c6da327995daef70cc0a 100644 (file)
@@ -109,22 +109,16 @@ void Framebuffer::update_attachment(unsigned mask) const
                                color_bufs.push_back(attch.attachment);
                }
 
-               if(color_bufs.empty())
-               {
-                       glDrawBuffer(GL_NONE);
-                       glReadBuffer(GL_NONE);
-               }
-               else if(color_bufs.size()==1)
-               {
-                       glDrawBuffer(color_bufs.front());
-                       glReadBuffer(color_bufs.front());
-               }
-               else
-               {
+               if(color_bufs.size()>1)
                        static Require _req(ARB_draw_buffers);
+
+               GLenum first_buffer = (color_bufs.empty() ? GL_NONE : color_bufs.front());
+               if(ARB_draw_buffers)
                        glDrawBuffers(color_bufs.size(), &color_bufs[0]);
-                       glReadBuffer(color_bufs.front());
-               }
+               else
+                       glDrawBuffer(first_buffer);
+
+               glReadBuffer(first_buffer);
        }
        else
                dirty |= mask;