Import glDrawBuffers() from WEBGL_draw_buffers extension (#2667)

This commit is contained in:
Christophe Dehais 2022-04-01 03:27:24 +02:00 committed by GitHub
parent 3ec6d59b47
commit f44818b548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 14 deletions

View File

@ -30,6 +30,7 @@
#define GL_IMPORT_NV___(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## NV)
#define GL_IMPORT_OES__(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## OES)
#define GL_IMPORT_IMG__(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## IMG)
#define GL_IMPORT_WEBGL(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## WEBGL)
#define GL_IMPORT_____x(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## XXXXX)
#if GL_IMPORT_TYPEDEFS
@ -595,7 +596,11 @@ GL_IMPORT_____x(true, PFNGLMEMORYBARRIERPROC, glMemoryBarri
GL_IMPORT_____x(true, PFNGLDISPATCHCOMPUTEPROC, glDispatchCompute);
GL_IMPORT_____x(true, PFNGLDISPATCHCOMPUTEINDIRECTPROC, glDispatchComputeIndirect);
#if BX_PLATFORM_EMSCRIPTEN
GL_IMPORT_WEBGL(true, PFNGLDRAWBUFFERSPROC, glDrawBuffers);
#else
GL_IMPORT_NV___(true, PFNGLDRAWBUFFERSPROC, glDrawBuffers);
#endif
GL_IMPORT_NV___(true, PFNGLGENQUERIESPROC, glGenQueries);
GL_IMPORT_NV___(true, PFNGLDELETEQUERIESPROC, glDeleteQueries);
GL_IMPORT_NV___(true, PFNGLBEGINQUERYPROC, glBeginQuery);
@ -671,7 +676,11 @@ GL_IMPORT______(true, PFNGLMEMORYBARRIERPROC, glMemoryBarri
GL_IMPORT______(true, PFNGLDISPATCHCOMPUTEPROC, glDispatchCompute);
GL_IMPORT______(true, PFNGLDISPATCHCOMPUTEINDIRECTPROC, glDispatchComputeIndirect);
# if BX_PLATFORM_EMSCRIPTEN
GL_IMPORT_WEBGL(true, PFNGLDRAWBUFFERSPROC, glDrawBuffers);
# else
GL_IMPORT______(true, PFNGLDRAWBUFFERSPROC, glDrawBuffers);
# endif
GL_IMPORT______(true, PFNGLGENQUERIESPROC, glGenQueries);
GL_IMPORT______(true, PFNGLDELETEQUERIESPROC, glDeleteQueries);
GL_IMPORT______(true, PFNGLBEGINQUERYPROC, glBeginQuery);

View File

@ -6799,22 +6799,19 @@ namespace bgfx { namespace gl
m_num = uint8_t(colorIdx);
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || s_renderGL->m_gles3 )
if (0 == colorIdx && BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
{
if (0 == colorIdx)
{
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
{
// When only depth is attached disable draw buffer to avoid
// GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER.
GL_CHECK(glDrawBuffer(GL_NONE) );
}
}
else
{
GL_CHECK(glDrawBuffers(colorIdx, buffers) );
}
// When only depth is attached disable draw buffer to avoid
// GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER.
GL_CHECK(glDrawBuffer(GL_NONE) );
}
else if (g_caps.limits.maxFBAttachments > 0)
{
GL_CHECK(glDrawBuffers(colorIdx, buffers) );
}
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) || s_renderGL->m_gles3)
{
// Disable read buffer to avoid GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER.
GL_CHECK(glReadBuffer(GL_NONE) );
}