From c764f9f2069f90ad82d4e00a1be8bca726801f66 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 22 Jan 2017 21:18:06 -0400 Subject: [PATCH] Support instancing on more systems. Note that GLSL 3 may not be supported everywhere that instancing is, and love_InstanceID requires GLSL 3 (but instanced vertex attributes do not). --HG-- branch : minor --- src/modules/graphics/opengl/OpenGL.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 92b2995ba..2ad700a05 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -280,6 +280,28 @@ void OpenGL::initOpenGLFunctions() else if (GLAD_NV_framebuffer_multisample) fp_glRenderbufferStorageMultisample = fp_glRenderbufferStorageMultisampleNV; } + + if (isInstancingSupported() && !(GLAD_VERSION_3_3 || GLAD_ES_VERSION_3_0)) + { + if (GLAD_ARB_instanced_arrays) + { + fp_glDrawArraysInstanced = fp_glDrawArraysInstancedARB; + fp_glDrawElementsInstanced = fp_glDrawElementsInstancedARB; + fp_glVertexAttribDivisor = fp_glVertexAttribDivisorARB; + } + else if (GLAD_EXT_instanced_arrays) + { + fp_glDrawArraysInstanced = fp_glDrawArraysInstancedEXT; + fp_glDrawElementsInstanced = fp_glDrawElementsInstancedEXT; + fp_glVertexAttribDivisor = fp_glVertexAttribDivisorEXT; + } + else if (GLAD_ANGLE_instanced_arrays) + { + fp_glDrawArraysInstanced = fp_glDrawArraysInstancedANGLE; + fp_glDrawElementsInstanced = fp_glDrawElementsInstancedANGLE; + fp_glVertexAttribDivisor = fp_glVertexAttribDivisorANGLE; + } + } } void OpenGL::initMaxValues() @@ -755,7 +777,8 @@ bool OpenGL::isPixelShaderHighpSupported() const bool OpenGL::isInstancingSupported() const { - return GLAD_ES_VERSION_3_0 || isCoreProfile(); + return GLAD_ES_VERSION_3_0 || GLAD_VERSION_3_3 + || GLAD_ARB_instanced_arrays || GLAD_EXT_instanced_arrays || GLAD_ANGLE_instanced_arrays; } int OpenGL::getMaxTextureSize() const