--- /dev/null
+#include "arb_draw_buffers.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLDRAWBUFFERSPROC glDrawBuffers = 0;
+
+Extension::SupportLevel init_arb_draw_buffers()
+{
+ if(is_version_at_least(2, 0))
+ {
+ glDrawBuffers = reinterpret_cast<PFNGLDRAWBUFFERSPROC>(get_proc_address("glDrawBuffers"));
+ return Extension::CORE;
+ }
+ if(is_supported("GL_ARB_draw_buffers"))
+ {
+ glDrawBuffers = reinterpret_cast<PFNGLDRAWBUFFERSPROC>(get_proc_address("glDrawBuffersARB"));
+ return Extension::EXTENSION;
+ }
+ return Extension::UNSUPPORTED;
+}
+
+Extension ARB_draw_buffers("GL_ARB_draw_buffers", init_arb_draw_buffers);
+
+} // namespace GL
+} // namespace Msp
--- /dev/null
+#ifndef MSP_GL_ARB_DRAW_BUFFERS_
+#define MSP_GL_ARB_DRAW_BUFFERS_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
+
+extern Extension ARB_draw_buffers;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
+#include "arb_draw_buffers.h"
#include "error.h"
#include "ext_framebuffer_blit.h"
#include "ext_framebuffer_object.h"
{
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];
}
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;