Fixed incomplete framebuffer.

This commit is contained in:
Branimir Karadžić 2014-02-24 22:00:26 -08:00
parent a4e189a366
commit 0fe44d7829
2 changed files with 19 additions and 1 deletions

View file

@ -80,6 +80,7 @@ typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count);
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices);
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);
typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap);
@ -118,6 +119,7 @@ typedef void (GL_APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size);
typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
typedef void (GL_APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);
typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
@ -211,6 +213,7 @@ GL_IMPORT______(false, PFNGLDISABLEPROC, glDisable);
GL_IMPORT______(false, PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray);
GL_IMPORT______(false, PFNGLDRAWARRAYSPROC, glDrawArrays);
GL_IMPORT______(true, PFNGLDRAWARRAYSINSTANCEDPROC, glDrawArraysInstanced);
GL_IMPORT______(true, PFNGLDRAWBUFFERPROC, glDrawBuffer);
GL_IMPORT______(false, PFNGLDRAWELEMENTSPROC, glDrawElements);
GL_IMPORT______(true, PFNGLDRAWELEMENTSINSTANCEDPROC, glDrawElementsInstanced);
GL_IMPORT______(false, PFNGLENABLEPROC, glEnable);
@ -248,6 +251,7 @@ GL_IMPORT______(false, PFNGLPIXELSTOREIPROC, glPixelStorei
GL_IMPORT______(true, PFNGLPROGRAMBINARYPROC, glProgramBinary);
GL_IMPORT______(true, PFNGLPROGRAMPARAMETERIPROC, glProgramParameteri);
GL_IMPORT______(true, PFNGLQUERYCOUNTERPROC, glQueryCounter);
GL_IMPORT______(true, PFNGLREADBUFFERPROC, glReadBuffer);
GL_IMPORT______(false, PFNGLREADPIXELSPROC, glReadPixels);
GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);

View file

@ -2150,7 +2150,8 @@ namespace bgfx
bool needResolve = false;
for (uint32_t ii = 0, colorIdx = 0; ii < _num; ++ii)
uint32_t colorIdx = 0;
for (uint32_t ii = 0; ii < _num; ++ii)
{
TextureHandle handle = _handles[ii];
if (isValid(handle) )
@ -2195,6 +2196,19 @@ namespace bgfx
}
}
if (BX_ENABLED(!BGFX_CONFIG_RENDERER_OPENGL) )
{
if (0 == colorIdx)
{
// When only depth is attached disable draw buffer to avoid
// GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER.
glDrawBuffer(GL_NONE);
}
// Disable read buffer to avoid GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER.
glReadBuffer(GL_NONE);
}
BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)
, "glCheckFramebufferStatus failed 0x%08x"
, glCheckFramebufferStatus(GL_FRAMEBUFFER)