Bug 953221 - Disable glDrawBuffer/glReadBuffer when no color attachment. r=bjacob

This is mainly for OSX where the OGL version requires this so that the
framebuffer complete checks pass.
This commit is contained in:
Dan Glastonbury 2014-01-24 14:01:10 +10:00
parent 1966c22b51
commit e291e9fb5f
2 changed files with 17 additions and 0 deletions

View File

@ -206,6 +206,18 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer *wfb)
if (!wfb) {
gl->fBindFramebuffer(target, 0);
// Restore draw/read buffers when switching back to default
// render target.
GLint drawBuffer = LOCAL_GL_COLOR_ATTACHMENT0;
gl->fGetIntegerv(LOCAL_GL_DRAW_BUFFER, &drawBuffer);
if (drawBuffer == LOCAL_GL_NONE)
gl->fDrawBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
GLint readBuffer = LOCAL_GL_COLOR_ATTACHMENT0;
gl->fGetIntegerv(LOCAL_GL_READ_BUFFER, &readBuffer);
if (readBuffer == LOCAL_GL_NONE)
gl->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
} else {
GLuint framebuffername = wfb->GLName();
gl->fBindFramebuffer(target, framebuffername);

View File

@ -727,6 +727,11 @@ WebGLFramebuffer::FinalizeAttachments() const
ColorAttachment(i).FinalizeAttachment(LOCAL_GL_COLOR_ATTACHMENT0 + i);
}
GLenum colorBufferSource =
ColorAttachment(0).IsDefined() ? LOCAL_GL_COLOR_ATTACHMENT0 : LOCAL_GL_NONE;
mContext->gl->fDrawBuffer(colorBufferSource);
mContext->gl->fReadBuffer(colorBufferSource);
if (DepthAttachment().IsDefined())
DepthAttachment().FinalizeAttachment(LOCAL_GL_DEPTH_ATTACHMENT);