diff --git a/src/glimports.h b/src/glimports.h index a01a33d65..d1ca30c4f 100644 --- a/src/glimports.h +++ b/src/glimports.h @@ -118,10 +118,6 @@ GL_IMPORT(true, PFNGLGETQUERYOBJECTUI64VEXTPROC, glGetQueryObjectui64vE GL_IMPORT(true, PFNGLSAMPLECOVERAGEARBPROC, glSampleCoverageARB); -GL_IMPORT(true, PFNGLDRAWARRAYSINSTANCEDARBPROC, glDrawArraysInstanced); -GL_IMPORT(true, PFNGLDRAWELEMENTSINSTANCEDARBPROC, glDrawElementsInstanced); -GL_IMPORT(true, PFNGLVERTEXATTRIBDIVISORARBPROC, glVertexAttribDivisor); - #if BGFX_CONFIG_DEBUG_GREMEDY GL_IMPORT(true, PFNGLSTRINGMARKERGREMEDYPROC, glStringMarkerGREMEDY); GL_IMPORT(true, PFNGLFRAMETERMINATORGREMEDYPROC, glFrameTerminatorGREMEDY); @@ -135,3 +131,7 @@ GL_IMPORT(true, PFNGLFRAMETERMINATORGREMEDYPROC, glFrameTerminatorGREME GL_IMPORT(true, PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC, glGetTranslatedShaderSourceANGLE); #endif // BGFX_CONFIG_RENDERER_ + +GL_IMPORT(true, PFNGLVERTEXATTRIBDIVISORBGFXPROC, glVertexAttribDivisor); +GL_IMPORT(true, PFNGLDRAWARRAYSINSTANCEDBGFXPROC, glDrawArraysInstanced); +GL_IMPORT(true, PFNGLDRAWELEMENTSINSTANCEDBGFXPROC, glDrawElementsInstanced); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 7015ce408..07ba5a126 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -27,6 +27,24 @@ namespace bgfx #include "glimports.h" #undef GL_IMPORT + static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/) + { + } + + static void GL_APIENTRY stubDrawArraysInstanced(GLenum _mode, GLint _first, GLsizei _count, GLsizei /*_primcount*/) + { + glDrawArrays(_mode, _first, _count); + } + + static void GL_APIENTRY stubDrawElementsInstanced(GLenum _mode, GLsizei _count, GLenum _type, const GLvoid* _indices, GLsizei /*_primcount*/) + { + glDrawElements(_mode, _count, _type, _indices); + } + + static PFNGLVERTEXATTRIBDIVISORBGFXPROC s_vertexAttribDivisor = stubVertexAttribDivisor; + static PFNGLDRAWARRAYSINSTANCEDBGFXPROC s_drawArraysInstanced = stubDrawArraysInstanced; + static PFNGLDRAWELEMENTSINSTANCEDBGFXPROC s_drawElementsInstanced = stubDrawElementsInstanced; + typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height); #if BX_PLATFORM_NACL @@ -358,6 +376,21 @@ namespace bgfx #endif // BX_PLATFORM_ } + if (NULL != glVertexAttribDivisor + && NULL != glDrawArraysInstanced + && NULL != glDrawElementsInstanced) + { + s_vertexAttribDivisor = glVertexAttribDivisor; + s_drawArraysInstanced = glDrawArraysInstanced; + s_drawElementsInstanced = glDrawElementsInstanced; + } + else + { + s_vertexAttribDivisor = stubVertexAttribDivisor; + s_drawArraysInstanced = stubDrawArraysInstanced; + s_drawElementsInstanced = stubDrawElementsInstanced; + } + m_flip = true; } @@ -1030,7 +1063,7 @@ namespace bgfx GL_CHECK(glEnableVertexAttribArray(loc) ); enabled |= 1<