From e0a2e7643f490bee69dfada6b029c8e02e6ede07 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 17 Oct 2014 23:09:44 +0300 Subject: [PATCH] Prefer glDrawBuffers over glDrawBuffer OpenGL ES does not have glDrawBuffer, so this logic change makes porting a bit easier. --- source/framebuffer.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index 8c618ce5..f4e5a944 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -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; -- 2.45.2