diff --git a/src/glimports.h b/src/glimports.h index b72b9ead..3118c761 100644 --- a/src/glimports.h +++ b/src/glimports.h @@ -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); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index bab965db..3a0a69e3 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -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)