Browse Source

Enable GLEW experimental mode only on a 3.2+ context so that OpenGL 2 extensions can be checked strictly.

Lasse Öörni 10 years ago
parent
commit
64600d5526
2 changed files with 8 additions and 2 deletions
  1. 8 0
      Source/ThirdParty/GLEW/glew.c
  2. 0 2
      Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

+ 8 - 0
Source/ThirdParty/GLEW/glew.c

@@ -29,6 +29,8 @@
 ** THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+// Modified by Lasse Oorni for Urho3D
+
 #include <glew.h>
 
 #if defined(_WIN32)
@@ -8927,6 +8929,12 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
     CONST_CAST(GLEW_VERSION_1_1)   = GLEW_VERSION_1_2   == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
   }
 
+  // Urho3D: GLEW does not query extensions properly on an OpenGL 3+ core context. Enable experimental mode in that case.
+  // However on OpenGL 2 we need to be strict about not using features that are not listed in extensions (for example
+  // instancing) even if the corresponding function pointers are non-null
+  if (GLEW_VERSION_3_2)
+    glewExperimental = GL_TRUE;
+
   /* query opengl extensions string */
   extStart = glGetString(GL_EXTENSIONS);
   if (extStart == 0)

+ 0 - 2
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -499,8 +499,6 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
         
         // If OpenGL extensions not yet initialized, initialize now
         #ifndef GL_ES_VERSION_2_0
-        // Work around GLEW failure to check extensions properly from a GL3 context
-        glewExperimental = GL_TRUE;
         GLenum err = glewInit();
         if (GLEW_OK != err)
         {