ecere/gfx/drivers/OpenGL: Fixed warnings
[sdk] / ecere / src / gfx / drivers / OpenGLDisplayDriver.ec
index 36af8ca..5baefff 100644 (file)
@@ -522,7 +522,7 @@ static int displayWidth, displayHeight;
 
 #define GL_CLAMP_TO_EDGE 0x812F
 
-static bool vboAvailable;
+/*static */bool vboAvailable;
 
 static bool useSingleGLContext = false;
 class OGLDisplay : struct
@@ -563,7 +563,11 @@ class OGLDisplay : struct
    int x, y;
 };
 
-#ifdef _DEBUG
+#if defined(_DEBUG) && !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && !defined(__ODROID__)
+//#define GL_DEBUGGING
+#endif
+
+#ifdef GL_DEBUGGING
 static void APIENTRY openglCallbackFunction(GLenum source,
                                            GLenum type,
                                            GLuint id,
@@ -647,8 +651,7 @@ class OGLIndices : struct
 int current;
 void * previous;
 
-#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && !defined(__ODROID__)
-#ifdef _DEBUG
+#ifdef GL_DEBUGGING
 static void setupDebugging()
 {
    if(glDebugMessageCallback)
@@ -656,7 +659,7 @@ static void setupDebugging()
       GLuint unusedIds = 0;
 
       glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
-      /*
+
       glDebugMessageCallback(openglCallbackFunction, null);
       glDebugMessageControl(GL_DONT_CARE,
           GL_DONT_CARE,
@@ -664,11 +667,9 @@ static void setupDebugging()
           0,
           &unusedIds,
           GL_TRUE);
-      */
    }
 }
 #endif
-#endif
 
 #if defined(__WIN32__)
 static HGLRC winCreateContext(HDC hdc)
@@ -844,6 +845,9 @@ class OpenGLDisplayDriver : DisplayDriver
 
       oglSystem.pow2textures = (extensions && strstr(extensions, "GL_ARB_texture_non_power_of_two")) ? false : true;
       glGetIntegerv(GL_MAX_TEXTURE_SIZE, &oglSystem.maxTextureSize);
+#ifdef DIAGNOSTICS
+      PrintLn("max texture size: ", oglSystem.maxTextureSize);
+#endif
    }
 
    bool CreateDisplaySystem(DisplaySystem displaySystem)
@@ -1283,7 +1287,7 @@ class OpenGLDisplayDriver : DisplayDriver
          PrintLn("vboAvailable is: ", vboAvailable);
 #endif
 
-#  ifdef _DEBUG
+#  ifdef GL_DEBUGGING
          setupDebugging();
 #  endif
 
@@ -2809,7 +2813,8 @@ class OpenGLDisplayDriver : DisplayDriver
          case vSync:
          {
 #if defined(__WIN32__)
-            wglSwapIntervalEXT(value ? 1 : 0);
+            if(wglSwapIntervalEXT)
+               wglSwapIntervalEXT(value ? 1 : 0);
 #endif
             break;
          }
@@ -3493,8 +3498,20 @@ class OpenGLDisplayDriver : DisplayDriver
 
          {
             OGLIndices oglIndices = primitive->data;
-            GLEAB eab = ((!display.display3D.collectingHits && oglIndices) ? oglIndices.buffer : noEAB);
-
+            GLEAB eab = ((!display.display3D.collectingHits && oglIndices && vboAvailable) ? oglIndices.buffer : noEAB);
+#if defined(ES1_1) || defined(ES2)
+            if(!vboAvailable && primitive->type.indices32bit)
+            {
+               uint16 * temp = new uint16[primitive->nIndices];
+               uint32 * src = (uint32 *)(oglIndices ? oglIndices.indices : primitive->indices);
+               int i;
+               for(i = 0; i < primitive->nIndices; i++)
+                  temp[i] = (uint16)src[i];
+               eab.draw(primitiveTypes[primitive->type.primitiveType], primitive->nIndices, GL_UNSIGNED_SHORT, temp);
+               delete temp;
+            }
+            else
+#endif
             eab.draw(primitiveTypes[primitive->type.primitiveType], primitive->nIndices,
                primitive->type.indices32bit ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
                eab.buffer ? 0 : (oglIndices ? oglIndices.indices : primitive->indices));