]> git.tdb.fi Git - libs/gl.git/blobdiff - source/framebuffer.cpp
Set all color attachments of a Framebuffer as draw buffers
[libs/gl.git] / source / framebuffer.cpp
index 43b0f94b82e4c882327ef686491453a1bc7cf263..98722195e32e8b10d40a43ab3d458d4c1ae5f4af 100644 (file)
@@ -1,3 +1,4 @@
+#include "arb_draw_buffers.h"
 #include "error.h"
 #include "ext_framebuffer_blit.h"
 #include "ext_framebuffer_object.h"
@@ -46,7 +47,8 @@ void Framebuffer::update_attachment(unsigned mask) const
 {
        if(current()==this)
        {
-               GLenum color_buf = GL_NONE;
+               std::vector<GLenum> color_bufs;
+               color_bufs.reserve(attachments.size());
                for(unsigned i=0; i<attachments.size(); ++i)
                {
                        const Attachment &attch = attachments[i];
@@ -69,10 +71,18 @@ void Framebuffer::update_attachment(unsigned mask) const
                        }
 
                        if(attch.attachment>=COLOR_ATTACHMENT0 && attch.attachment<=COLOR_ATTACHMENT3)
-                               color_buf = attch.attachment;
+                               color_bufs.push_back(attch.attachment);
                }
 
-               glDrawBuffer(color_buf);
+               if(color_bufs.empty())
+                       glDrawBuffer(GL_NONE);
+               else if(color_bufs.size()==1)
+                       glDrawBuffer(color_bufs.front());
+               else
+               {
+                       static Require _req(ARB_draw_buffers);
+                       glDrawBuffers(color_bufs.size(), &color_bufs[0]);
+               }
        }
        else
                dirty |= mask;