ecere/gfx/drivers/OpenGL: Core profile support
authorJerome St-Louis <jerome@ecere.com>
Mon, 11 Jul 2016 11:03:34 +0000 (07:03 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 21:35:41 +0000 (17:35 -0400)
- Can set glCapabilities.compatible = false on top level Window to request a core profile
- Setting up a VAO per display
- Renamed glcaps -> glCaps

ecere/src/gfx/Display.ec
ecere/src/gfx/DisplaySystem.ec
ecere/src/gfx/drivers/OpenGLDisplayDriver.ec
ecere/src/gfx/drivers/gl3/glHelpers.h
ecere/src/gfx/drivers/gl3/glab.ec
ecere/src/gfx/drivers/gl3/immediate.ec
ecere/src/gfx/drivers/gl3/matrixStack.ec
ecere/src/gui/Window.ec

index 6062969..f1d0ced 100644 (file)
@@ -38,19 +38,27 @@ import "OpenGLDisplayDriver"
 public class GLCapabilities : uint
 {
 public:
+   // Expect reloading graphics
+   bool compatible      :1;
+   bool vertexBuffer    :1;
+   bool quads           :1;
+   bool intAndDouble    :1;
+   bool legacyFormats   :1;
+   bool nonPow2Textures :1;
+   bool vertexPointer   :1;
+
+   // Should be able to toggle without reloading
    bool legacy          :1;
    bool shaders         :1;
-   bool nonPow2Textures :1;
-   bool vertexBuffer    :1;
+   bool fixedFunction   :1;
+   bool immediate       :1;
    bool frameBuffer     :1;
    bool pointSize       :1;
-
-   // To be able to disable these at runtime independently...
-   bool immediate       :1;
-   bool fixedFunction   :1;
-   bool quads           :1;
-   bool intAndDouble    :1;
+   bool vao             :1;
+   bool select          :1;
    // bool mapBuffer       :1;
+
+   bool debug           :1;
 };
 
 public enum RenderState { fillMode = 1, depthTest, depthWrite, fogDensity, fogColor, blend, ambient, alphaWrite, antiAlias, vSync };
index b49a03d..2456012 100644 (file)
@@ -337,6 +337,7 @@ private:
    public PixelFormat pixelFormat;
    public DisplayFlags flags;
    int numDisplays;
+   GLCapabilities glCapabilities;
 
    OldList resources;
 
index 01ac726..a35d7e0 100644 (file)
@@ -162,11 +162,11 @@ private:
 
 default:
 // Capabilities Global set to capabilities of Display being rendered to
-GLCapabilities glcaps;
+GLCapabilities glCaps;
 // Requiring Graphics Reload:
-bool glcaps_nonPow2Textures, glcaps_vertexBuffer, glcaps_quads, glcaps_intAndDouble;
+bool glCaps_nonPow2Textures, glCaps_vertexBuffer, glCaps_quads, glCaps_intAndDouble, glCaps_legacyFormats, glCaps_compatible, glCaps_vertexPointer;
 // Might toggle without Reload:
-bool glcaps_shaders, glcaps_fixedFunction, glcaps_immediate, glcaps_legacy, glcaps_pointSize, glcaps_frameBuffer;
+bool glCaps_core, glCaps_shaders, glCaps_fixedFunction, glCaps_immediate, glCaps_legacy, glCaps_pointSize, glCaps_frameBuffer, glCaps_vao, glCaps_select;
 // bool mapBuffer;
 private:
 
@@ -242,8 +242,7 @@ static void setupDebugging()
 static GLuint stippleTexture;
 static bool stippleEnabled;
 
-                              // TOCHECK: Do we really need to pass glcaps_shaders?
-public void glsupLineStipple( int i, unsigned short j )
+public void glsupLineStipple( int i, uint16 j )
 {
    uint texture[1*16];
    int x;
@@ -314,18 +313,18 @@ static inline uint getPrimitiveType(RenderPrimitiveType type)
       GL_LINE_STRIP
    };
    // NOTE: This will only work for single quads
-   return (type == quads && !glcaps_quads) ? GL_TRIANGLE_FAN : primitiveTypes[type];
+   return (type == quads && !glCaps_quads) ? GL_TRIANGLE_FAN : primitiveTypes[type];
 }
 
 public void GLSetupTexturing(bool enable)
 {
 #if ENABLE_GL_SHADERS
-   if(glcaps_shaders)
+   if(glCaps_shaders)
       shader_texturing(enable);
 #endif
 
 #if ENABLE_GL_FFP
-   if(!glcaps_shaders)
+   if(!glCaps_shaders)
       (enable ? glEnable : glDisable)(GL_TEXTURE_2D);
 #endif
 }
@@ -333,12 +332,12 @@ public void GLSetupTexturing(bool enable)
 public void GLSetupFog(bool enable)
 {
 #if ENABLE_GL_SHADERS
-   if(glcaps_shaders)
+   if(glCaps_shaders)
       shader_fog(enable);
 #endif
 
 #if ENABLE_GL_FFP
-   if(!glcaps_shaders)
+   if(!glCaps_shaders)
       (enable ? glEnable : glDisable)(GL_FOG);
 #endif
 }
@@ -349,12 +348,12 @@ public void GLSetupLighting(bool enable)
 {
    lightingEnabled = enable;
 #if ENABLE_GL_SHADERS
-   if(glcaps_shaders)
+   if(glCaps_shaders)
       shader_lighting(enable);
 #endif
 
 #if ENABLE_GL_FFP
-   if(!glcaps_shaders)
+   if(!glCaps_shaders)
       (enable ? glEnable : glDisable)(GL_LIGHTING);
 #endif
 }
@@ -400,11 +399,14 @@ class OGLDisplay : struct
 #endif
 
    GLCapabilities capabilities, originalCapabilities;
+   bool compat;
+   int version;
 
    ColorAlpha * flippingBuffer;
    int flipBufH, flipBufW;
    bool depthWrite;
    int x, y;
+   uint vao;
 };
 
 class OGLSystem : struct
@@ -430,6 +432,8 @@ class OGLSystem : struct
    GLXDrawable glxDrawable;
 #endif
    GLCapabilities capabilities;
+   bool compat;
+   int version;
 
    // Buffer Data
    uint16 *shortBDBuffer;
@@ -467,7 +471,7 @@ int current;
 void * previous;
 
 #if defined(__WIN32__)
-static HGLRC winCreateContext(HDC hdc, int * contextVersion, bool * isCompatible)
+static HGLRC winCreateContext(HDC hdc, int * contextVersion, bool * isCompatible, bool compatible)
 {
    HGLRC result = 0;
    if(wglCreateContextAttribsARB)
@@ -479,7 +483,7 @@ static HGLRC winCreateContext(HDC hdc, int * contextVersion, bool * isCompatible
                                                  { 2, 1 }, { 2, 0 }
       };
 
-      bool tryingCompat = true;
+      bool tryingCompat = compatible;
       int v = 0;
       while(!result)
       {
@@ -670,24 +674,36 @@ class OpenGLDisplayDriver : DisplayDriver
       glGetIntegerv(GL_MAX_TEXTURE_SIZE, &oglSystem.maxTextureSize);
 
 #if defined(_GLES)
-      capabilities = { fixedFunction = true, vertexBuffer = true, pointSize = true, frameBuffer = extensions && strstr(extensions, "GL_OES_framebuffer_object") };
+      capabilities = { fixedFunction = true, vertexPointer = true, vertexBuffer = true, pointSize = true, legacyFormats = true, frameBuffer = extensions && strstr(extensions, "GL_OES_framebuffer_object") };
 #elif defined(_GLES2)
-      capabilities = { glcaps_shaders = true, vertexBuffer = true, pointSize = true, frameBuffer = true };
+      capabilities = { glCaps_shaders = true, vertexBuffer = true, pointSize = true, frameBuffer = true, legacyFormats = true };
 #else
       capabilities =
       {
          nonPow2Textures = extensions && strstr(extensions, "GL_ARB_texture_non_power_of_two");
          intAndDouble = true;
-         pointSize = true;
+#ifdef GL_DEBUGGING
+         debug = true;
+#endif
+         compatible = oglDisplay.compat;
+         pointSize = oglDisplay.compat;
 #if ENABLE_GL_LEGACY
-         legacy         = glBegin != null;
-         immediate      = glBegin != null;
-         fixedFunction  = glBegin != null;
-         quads          = glBegin != null;
+         legacy         = glBegin != null && oglDisplay.compat;
+         legacyFormats  = glBegin != null && oglDisplay.compat;
+         immediate      = glBegin != null && oglDisplay.compat;
+         fixedFunction  = glBegin != null && oglDisplay.compat;
+         quads          = glBegin != null && oglDisplay.compat;
+         select         = glSelectBuffer != null && oglDisplay.compat;
 #endif
 #if ENABLE_GL_SHADERS
          shaders = glCreateProgram != null;
 #endif
+#if ENABLE_GL_POINTER
+         vertexPointer = oglDisplay.compat;
+#endif
+#if ENABLE_GL_VAO
+         vao = glBindVertexArray != null && !oglDisplay.compat;
+#endif
 #if ENABLE_GL_FBO
          shaders = glBindFramebuffer != null;
 #endif
@@ -714,7 +730,7 @@ class OpenGLDisplayDriver : DisplayDriver
 #elif defined(_GLES2)
       oglSystem.capabilities = { shaders = true, vertexBuffer = true, frameBuffer = true, pointSize = true };
 #else
-      oglSystem.capabilities = { shaders = true, fixedFunction = true, immediate = true, legacy = true, pointSize = true, quads = true, intAndDouble = true, vertexBuffer = true, frameBuffer = true, nonPow2Textures = true };
+      oglSystem.capabilities = { compatible = glCaps_compatible, shaders = true, fixedFunction = true, immediate = true, legacy = true, pointSize = true, quads = true, intAndDouble = true, vertexBuffer = true, frameBuffer = true, vao = true, nonPow2Textures = true };
 #endif
 
 #ifdef DIAGNOSTICS
@@ -816,7 +832,7 @@ class OpenGLDisplayDriver : DisplayDriver
 #ifdef DIAGNOSTICS
                      PrintLn("winCreateContext()");
 #endif
-                     oglSystem.glrc = winCreateContext(oglSystem.hdc, null, null);
+                     oglSystem.glrc = winCreateContext(oglSystem.hdc, &oglSystem.version, &oglSystem.compat, displaySystem.glCapabilities.compatible);
 #ifdef DIAGNOSTICS
                      PrintLn("wglMakeCurrent()");
 #endif
@@ -869,7 +885,7 @@ class OpenGLDisplayDriver : DisplayDriver
          glShadeModel(GL_FLAT);
 
 #if !defined(_GLES)
-         if(!glcaps_shaders)
+         if(!glCaps_shaders)
             GLLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
 #endif
          glFogi(GL_FOG_MODE, GL_EXP);
@@ -1027,13 +1043,16 @@ class OpenGLDisplayDriver : DisplayDriver
       SETCAPS(oglDisplay.capabilities);
 
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
       {
 #if ENABLE_GL_LEGACY
-         glDisableClientState(GL_VERTEX_ARRAY);
-         glDisableClientState(GL_NORMAL_ARRAY);
-         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-         glDisableClientState(GL_COLOR_ARRAY);
+         if(oglDisplay.compat)
+         {
+            glDisableClientState(GL_VERTEX_ARRAY);
+            glDisableClientState(GL_NORMAL_ARRAY);
+            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+            glDisableClientState(GL_COLOR_ARRAY);
+         }
 #endif
          loadShaders(display.displaySystem, "<:ecere>shaders/fixed.vertex", "<:ecere>shaders/fixed.frag");
       }
@@ -1044,11 +1063,18 @@ class OpenGLDisplayDriver : DisplayDriver
          glDisableVertexAttribArray(GLBufferContents::normal);
          glDisableVertexAttribArray(GLBufferContents::texCoord);
          glDisableVertexAttribArray(GLBufferContents::vertex);
+         glBindVertexArray(0);
          glUseProgram(0);
       }
 #endif
 
 #endif
+
+#if ENABLE_GL_VAO
+      if(glCaps_vao)
+         glBindVertexArray(oglDisplay.vao);
+#endif
+
       GLEnableClientState(VERTICES);
 
       GLABBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -1078,7 +1104,7 @@ class OpenGLDisplayDriver : DisplayDriver
          GLOrtho(0,display.width,display.height,0,0.0,1.0);
 
 #if ENABLE_GL_FFP
-      if(!glcaps_shaders)
+      if(!glCaps_shaders)
       {
          glShadeModel(GL_FLAT);
          /*
@@ -1122,7 +1148,7 @@ class OpenGLDisplayDriver : DisplayDriver
 #if defined(__WIN32__)
          oglDisplay.hdc = GetDC(display.window);
          SetPixelFormat(oglDisplay.hdc, oglSystem.format, &oglSystem.pfd);
-         if((oglDisplay.glrc = winCreateContext(oglDisplay.hdc, null, null)))
+         if((oglDisplay.glrc = winCreateContext(oglDisplay.hdc, &oglDisplay.version, &oglDisplay.compat, (*&display.glCapabilities).compatible)))
          {
             wglShareLists(oglSystem.glrc, oglDisplay.glrc);
             wglMakeCurrent(oglDisplay.hdc, oglDisplay.glrc);
@@ -1152,6 +1178,11 @@ class OpenGLDisplayDriver : DisplayDriver
          // visualInfo = oglSystem.visualInfo;
 //#endif
          */
+#if !defined(__APPLE__)
+         oglDisplay.compat = true;
+         oglDisplay.version = 4;
+#endif
+
          if(visualInfo)
          {
             //printf("visualInfo is not null\n");
@@ -1197,7 +1228,10 @@ class OpenGLDisplayDriver : DisplayDriver
 #endif
 
 #  ifdef GL_DEBUGGING
-         setupDebugging();
+         if(oglDisplay.capabilities.debug)
+            setupDebugging();
+#else
+         oglDisplay.capabilities.debug = false;
 #  endif
 
 #endif
@@ -1214,17 +1248,17 @@ class OpenGLDisplayDriver : DisplayDriver
 
             oglDisplay.originalCapabilities = oglDisplay.capabilities;
 
-            // Re-enable glcaps_shaders if no fixed function support
+            // Re-enable glCaps_shaders if no fixed function support
             if(!oglDisplay.capabilities.fixedFunction)
                capabilities.shaders = true;
-            // Re-enable fixed function if no glcaps_shaders support
+            // Re-enable fixed function if no glCaps_shaders support
             if(!oglDisplay.capabilities.shaders)
             {
                capabilities.fixedFunction = true;
                capabilities.shaders = false;
             }
 
-            // Disable things that don't work with glcaps_shaders
+            // Disable things that don't work with glCaps_shaders
             if(capabilities.shaders)
             {
                capabilities.fixedFunction = false;
@@ -1243,6 +1277,14 @@ class OpenGLDisplayDriver : DisplayDriver
             oglSystem.capabilities = oglDisplay.capabilities;
          }
 
+#if ENABLE_GL_VAO
+         if(oglDisplay.capabilities.vao)
+         {
+            glGenVertexArrays(1, &oglDisplay.vao);
+            glBindVertexArray(oglDisplay.vao);
+         }
+#endif
+
          initialDisplaySetup(display);
       }
 
@@ -1355,7 +1397,7 @@ class OpenGLDisplayDriver : DisplayDriver
 
          oglDisplay.pBuffer = wglCreatePbufferARB(oglSystem.hdc, pixelFormat, width, height, attributes);
          oglDisplay.hdc = wglGetPbufferDCARB(oglDisplay.pBuffer);
-         if((oglDisplay.glrc = winCreateContext(oglDisplay.hdc, null, null)))
+         if((oglDisplay.glrc = winCreateContext(oglDisplay.hdc, null, null, oglDisplay.capabilities.compatible)))
          {
             BITMAPINFO * info;
             HDC hdc = GetDC(display.window);
@@ -1664,6 +1706,15 @@ class OpenGLDisplayDriver : DisplayDriver
 
    void StartUpdate(Display display)
    {
+#if ENABLE_GL_VAO
+      if(glCaps_vao)
+      {
+         OGLDisplay oglDisplay = display.driverData;
+         glBindVertexArray(oglDisplay.vao);
+      }
+#endif
+      GLABBindBuffer(GL_ARRAY_BUFFER, 0);
+      GLABBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    }
 
    void EndUpdate(Display display)
@@ -2476,7 +2527,7 @@ class OpenGLDisplayDriver : DisplayDriver
       {
          glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 #if ENABLE_GL_LEGACY
-         if(glcaps_legacy)
+         if(glCaps_legacy)
          {
             glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap.stride);
             glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
@@ -2544,7 +2595,7 @@ class OpenGLDisplayDriver : DisplayDriver
       {
          glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 #if ENABLE_GL_LEGACY
-         if(glcaps_legacy)
+         if(glCaps_legacy)
          {
             glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap.stride);
             glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
@@ -2662,7 +2713,7 @@ class OpenGLDisplayDriver : DisplayDriver
       if(stipple)
       {
 #if ENABLE_GL_LEGACY
-         if(glcaps_legacy)
+         if(glCaps_legacy)
          {
             glLineStipple(1, (uint16)stipple);
             glEnable(GL_LINE_STIPPLE);
@@ -2677,7 +2728,7 @@ class OpenGLDisplayDriver : DisplayDriver
       else
       {
 #if ENABLE_GL_LEGACY
-         if(glcaps_legacy)
+         if(glCaps_legacy)
             glDisable(GL_LINE_STIPPLE);
          else
 #endif
@@ -2707,7 +2758,7 @@ class OpenGLDisplayDriver : DisplayDriver
             break;
          case fillMode:
 #if ENABLE_GL_LEGACY
-            if(glcaps_legacy)
+            if(glCaps_legacy)
                glPolygonMode(GL_FRONT_AND_BACK, ((FillModeValue)value == solid) ? GL_FILL : GL_LINE);
 #endif
             break;
@@ -2722,24 +2773,24 @@ class OpenGLDisplayDriver : DisplayDriver
          {
             float color[4] = { ((Color)value).r/255.0f, ((Color)value).g/255.0f, ((Color)value).b/255.0f, 1.0f };
 #if ENABLE_GL_SHADERS
-            if(glcaps_shaders)
+            if(glCaps_shaders)
                shader_fogColor(color[0], color[1], color[2]);
 #endif
 
 #if ENABLE_GL_FFP
-            if(!glcaps_shaders)
+            if(!glCaps_shaders)
                glFogfv(GL_FOG_COLOR, (float *)&color);
 #endif
             break;
          }
          case fogDensity:
 #if ENABLE_GL_SHADERS
-            if(glcaps_shaders)
+            if(glCaps_shaders)
                shader_fogDensity((float)(RenderStateFloat { ui = value }.f * nearPlane));
 #endif
 
 #if ENABLE_GL_FFP
-            if(!glcaps_shaders)
+            if(!glCaps_shaders)
                glFogf(GL_FOG_DENSITY, (float)(RenderStateFloat { ui = value }.f * nearPlane));
 #endif
             break;
@@ -2751,12 +2802,12 @@ class OpenGLDisplayDriver : DisplayDriver
          case ambient:
          {
 #if ENABLE_GL_SHADERS
-            if(glcaps_shaders)
+            if(glCaps_shaders)
                shader_setGlobalAmbient(((Color)value).r / 255.0f, ((Color)value).g / 255.0f, ((Color)value).b / 255.0f, 1.0f);
 #endif
 
 #if ENABLE_GL_FFP
-            if(!glcaps_shaders)
+            if(!glCaps_shaders)
             {
                float ambient[4] = { ((Color)value).r/255.0f, ((Color)value).g/255.0f, ((Color)value).b/255.0f, 1.0f };
                glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
@@ -2783,12 +2834,12 @@ class OpenGLDisplayDriver : DisplayDriver
    void SetLight(Display display, int id, Light light)
    {
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
          shader_setLight(display, id, light);
 #endif
 
 #if ENABLE_GL_FFP
-      if(!glcaps_shaders)
+      if(!glCaps_shaders)
       {
          if(light != null)
          {
@@ -3008,7 +3059,7 @@ class OpenGLDisplayDriver : DisplayDriver
 
          GLSetupLighting(true);
 #if ENABLE_GL_FFP
-         if(!glcaps_shaders)
+         if(!glCaps_shaders)
             glShadeModel(GL_SMOOTH);
 #endif
          glDepthMask((byte)bool::true);
@@ -3034,12 +3085,12 @@ class OpenGLDisplayDriver : DisplayDriver
          GLDisableClientState(COLORS);
 
 #if ENABLE_GL_SHADERS
-         if(glcaps_shaders)
+         if(glCaps_shaders)
             shader_setPerVertexColor(false);
 #endif
 
 #if ENABLE_GL_FFP
-         if(!glcaps_shaders)
+         if(!glCaps_shaders)
             glShadeModel(GL_FLAT);
 #endif
          glEnable(GL_BLEND);
@@ -3063,7 +3114,7 @@ class OpenGLDisplayDriver : DisplayDriver
       if(material.flags.doubleSided)
       {
 #if ENABLE_GL_FFP
-         if(!glcaps_shaders)
+         if(!glCaps_shaders)
             GLLightModeli(GL_LIGHT_MODEL_TWO_SIDE, !material.flags.singleSideLight);
 #endif
          glDisable(GL_CULL_FACE);
@@ -3071,7 +3122,7 @@ class OpenGLDisplayDriver : DisplayDriver
       else
       {
 #if ENABLE_GL_FFP
-         if(!glcaps_shaders)
+         if(!glCaps_shaders)
             GLLightModeli(GL_LIGHT_MODEL_TWO_SIDE, bool::false);
 #endif
          glEnable(GL_CULL_FACE);
@@ -3108,12 +3159,12 @@ class OpenGLDisplayDriver : DisplayDriver
          GLSetupTexturing(false);
 
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
          shader_setMaterial(material, mesh.flags.colors);
 #endif
 
 #if ENABLE_GL_FFP
-      if(!glcaps_shaders)
+      if(!glCaps_shaders)
       {
          if(mesh.flags.colors)
          {
@@ -3155,27 +3206,27 @@ class OpenGLDisplayDriver : DisplayDriver
          SETCAPS(oglSystem.capabilities);
          if(!mesh.flags.vertices)
          {
-            oglMesh.vertices.free(glcaps_vertexBuffer);
+            oglMesh.vertices.free(glCaps_vertexBuffer);
             delete mesh.vertices;
          }
          if(!mesh.flags.normals)
          {
-            oglMesh.normals.free(glcaps_vertexBuffer);
+            oglMesh.normals.free(glCaps_vertexBuffer);
             delete mesh.normals;
          }
          if(!mesh.flags.texCoords1)
          {
-            oglMesh.texCoords.free(glcaps_vertexBuffer);
+            oglMesh.texCoords.free(glCaps_vertexBuffer);
             delete mesh.texCoords;
          }
          if(!mesh.flags.texCoords2)
          {
-            oglMesh.texCoords2.free(glcaps_vertexBuffer);
+            oglMesh.texCoords2.free(glCaps_vertexBuffer);
             // delete mesh.texCoords2;
          }
          if(!mesh.flags.colors)
          {
-            oglMesh.colors.free(glcaps_vertexBuffer);
+            oglMesh.colors.free(glCaps_vertexBuffer);
             delete mesh.colors;
          }
          if(!mesh.flags)
@@ -3267,7 +3318,7 @@ class OpenGLDisplayDriver : DisplayDriver
    {
       OGLSystem oglSystem = displaySystem.driverData;
       SETCAPS(oglSystem.capabilities);
-      if(glcaps_vertexBuffer)
+      if(glCaps_vertexBuffer)
       {
          OGLMesh oglMesh = mesh.data;
          if(!flags) flags = mesh.flags;
@@ -3302,7 +3353,7 @@ class OpenGLDisplayDriver : DisplayDriver
       SETCAPS(oglSystem.capabilities);
       if(oglIndices)
       {
-         oglIndices.buffer.free(glcaps_vertexBuffer);
+         oglIndices.buffer.free(glCaps_vertexBuffer);
          delete oglIndices.indices;
          delete oglIndices;
       }
@@ -3323,10 +3374,9 @@ class OpenGLDisplayDriver : DisplayDriver
    {
       OGLSystem oglSystem = displaySystem.driverData;
       SETCAPS(oglSystem.capabilities);
-      if(glcaps_vertexBuffer)
+      if(glCaps_vertexBuffer)
       {
-#if !ENABLE_GL_INTDBL
-         if(indices32bit)
+         if(!glCaps_intAndDouble && indices32bit)
          {
             if(!oglIndices.buffer.buffer)
                glGenBuffers(1, &oglIndices.buffer.buffer);
@@ -3347,12 +3397,12 @@ class OpenGLDisplayDriver : DisplayDriver
                   b[i] = (uint16)pointer[i];
 
                glBufferData(GL_ELEMENT_ARRAY_BUFFER, nIndices * sizeof(uint16), b, GL_STATIC_DRAW);
+            }
          }
          else
-#endif
-         oglIndices.buffer.allocate(
-            nIndices * (indices32bit ? sizeof(uint32) : sizeof(uint16)),
-            oglIndices.indices, staticDraw);
+            oglIndices.buffer.allocate(
+               nIndices * (indices32bit ? sizeof(uint32) : sizeof(uint16)),
+               oglIndices.indices, staticDraw);
       }
    }
 
@@ -3368,7 +3418,7 @@ class OpenGLDisplayDriver : DisplayDriver
 #if defined(__WIN32__)
       if(glUnlockArraysEXT)
 #endif
-         if(!glcaps_vertexBuffer && display.display3D.mesh)
+         if(!glCaps_vertexBuffer && display.display3D.mesh)
             glUnlockArraysEXT();
 #endif
       if(mesh)
@@ -3439,7 +3489,7 @@ class OpenGLDisplayDriver : DisplayDriver
 #if defined(__WIN32__)
          if(glLockArraysEXT)
 #endif
-            if(!glcaps_vertexBuffer)
+            if(!glCaps_vertexBuffer)
                glLockArraysEXT(0, mesh.nVertices);
 #endif
       }
@@ -3455,9 +3505,8 @@ class OpenGLDisplayDriver : DisplayDriver
       else
       {
          OGLIndices oglIndices = primitive->data;
-         GLEAB eab = ((!display.display3D.collectingHits && oglIndices && glcaps_vertexBuffer) ? oglIndices.buffer : noEAB);
-#if !ENABLE_GL_INTDBL
-         if(!glcaps_vertexBuffer && primitive->type.indices32bit)
+         GLEAB eab = ((!display.display3D.collectingHits && oglIndices && glCaps_vertexBuffer) ? oglIndices.buffer : noEAB);
+         if(!glCaps_intAndDouble && !glCaps_vertexBuffer && primitive->type.indices32bit)
          {
             uint16 * temp = new uint16[primitive->nIndices];
             uint32 * src = (uint32 *)(oglIndices ? oglIndices.indices : primitive->indices);
@@ -3468,7 +3517,6 @@ class OpenGLDisplayDriver : DisplayDriver
             delete temp;
          }
          else
-#endif
             eab.draw(getPrimitiveType(primitive->type.primitiveType), primitive->nIndices,
                primitive->type.indices32bit ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
                eab.buffer ? 0 : (oglIndices ? oglIndices.indices : primitive->indices));
index 6d621ab..44aaee3 100644 (file)
 #define ENABLE_GL_INTDBL   (!defined(_GLES) && !defined(_GLES2))
 #define ENABLE_GL_MAPBUF   (!defined(_GLES) && !defined(_GLES2))
 #define ENABLE_GL_SELECT   (!defined(_GLES) && !defined(_GLES2))
+#define ENABLE_GL_VAO      (!defined(_GLES) && !defined(_GLES2))
 #define ENABLE_GL_COLORMAT (ENABLE_GL_FFP   && !defined(_GLES))
 
 #if ENABLE_GL_SHADERS && ENABLE_GL_FFP
-   #define GLEnableClientState            (glcaps_shaders ? glEnableVertexAttribArray : glEnableClientState)
-   #define GLDisableClientState           (glcaps_shaders ? glDisableVertexAttribArray : glDisableClientState)
-   #define VERTICES                       (glcaps_shaders ? GLBufferContents::vertex : GL_VERTEX_ARRAY)
-   #define NORMALS                        (glcaps_shaders ? GLBufferContents::normal : GL_NORMAL_ARRAY)
-   #define TEXCOORDS                      (glcaps_shaders ? GLBufferContents::texCoord : GL_TEXTURE_COORD_ARRAY)
-   #define COLORS                         (glcaps_shaders ? GLBufferContents::color : GL_COLOR_ARRAY)
-   #define GLVertexPointer(n, t, s, p)    (glcaps_shaders ? glVertexAttribPointer(GLBufferContents::vertex,   n, t, GL_FALSE, s, p) : glVertexPointer(n, t, s, p))
-   #define GLColorPointer(n, t, s, p)     (glcaps_shaders ? glVertexAttribPointer(GLBufferContents::color,    n, t, GL_FALSE, s, p) : glColorPointer(n, t, s, p))
-   #define GLTexCoordPointer(n, t, s, p)  (glcaps_shaders ? glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p) : glTexCoordPointer(n, t, s, p))
+   #define GLEnableClientState            (glCaps_shaders ? glEnableVertexAttribArray : glEnableClientState)
+   #define GLDisableClientState           (glCaps_shaders ? glDisableVertexAttribArray : glDisableClientState)
+   #define VERTICES                       (glCaps_shaders ? GLBufferContents::vertex : GL_VERTEX_ARRAY)
+   #define NORMALS                        (glCaps_shaders ? GLBufferContents::normal : GL_NORMAL_ARRAY)
+   #define TEXCOORDS                      (glCaps_shaders ? GLBufferContents::texCoord : GL_TEXTURE_COORD_ARRAY)
+   #define COLORS                         (glCaps_shaders ? GLBufferContents::color : GL_COLOR_ARRAY)
+   #define GLVertexPointer(n, t, s, p)    (glCaps_shaders ? glVertexAttribPointer(GLBufferContents::vertex,   n, t, GL_FALSE, s, p) : glVertexPointer(n, t, s, p))
+   #define GLColorPointer(n, t, s, p)     (glCaps_shaders ? glVertexAttribPointer(GLBufferContents::color,    n, t, GL_FALSE, s, p) : glColorPointer(n, t, s, p))
+   #define GLTexCoordPointer(n, t, s, p)  (glCaps_shaders ? glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p) : glTexCoordPointer(n, t, s, p))
 #elif ENABLE_GL_SHADERS
    #define GLEnableClientState            glEnableVertexAttribArray
    #define GLDisableClientState           glDisableVertexAttribArray
 #endif
 
 #if ENABLE_GL_INTDBL && ENABLE_GL_SHADERS
-   #define GLLoadMatrixd(m)               (glcaps_fixedFunction ? glLoadMatrixd(m) : glmsLoadMatrixd(m))
-   #define GLMultMatrixd(m)               (glcaps_fixedFunction ? glMultMatrixd(m) : glmsMultMatrixd(m))
-   #define GLFrustum(a,b,c,d,e,f)         (glcaps_fixedFunction ? glFrustum(a,b,c,d,e,f) : glmsFrustum(a,b,c,d,e,f))
-   #define GLOrtho(a,b,c,d,e,f)           (glcaps_fixedFunction ? glOrtho(a,b,c,d,e,f) : glmsOrtho(a,b,c,d,e,f))
-   #define GLScaled(x, y, z)              (glcaps_fixedFunction ? glScaled(x, y, z) : glmsScaled(x,y,z))
-   #define GLScalef(x, y, z)              (glcaps_fixedFunction ? glScalef(x, y, z) : glmsScaled(x,y,z))
-   #define GLTranslated(x, y, z)          (glcaps_fixedFunction ? glTranslated(x,y,z) : glmsTranslated(x,y,z))
-   #define GLRotated(a, x, y, z)          (glcaps_fixedFunction ? glRotated(a, x,y,z) : glmsRotated(a,x,y,z))
-   #define GLMatrixMode(m)                (glcaps_fixedFunction ? glMatrixMode(m) : glmsMatrixMode(m))
-   #define GLLoadIdentity()               (glcaps_fixedFunction ? glLoadIdentity() : glmsLoadIdentity())
-   #define GLPushMatrix()                 (glcaps_fixedFunction ? glPushMatrix() : glmsPushMatrix())
-   #define GLPopMatrix()                  (glcaps_fixedFunction ? glPopMatrix() : glmsPopMatrix())
-   #define GLFlushMatrices()              (glcaps_fixedFunction ? (void)0 : glmsFlushMatrices())
+   #define GLLoadMatrixd(m)               (glCaps_fixedFunction ? glLoadMatrixd(m) : glmsLoadMatrixd(m))
+   #define GLMultMatrixd(m)               (glCaps_fixedFunction ? glMultMatrixd(m) : glmsMultMatrixd(m))
+   #define GLFrustum(a,b,c,d,e,f)         (glCaps_fixedFunction ? glFrustum(a,b,c,d,e,f) : glmsFrustum(a,b,c,d,e,f))
+   #define GLOrtho(a,b,c,d,e,f)           (glCaps_fixedFunction ? glOrtho(a,b,c,d,e,f) : glmsOrtho(a,b,c,d,e,f))
+   #define GLScaled(x, y, z)              (glCaps_fixedFunction ? glScaled(x, y, z) : glmsScaled(x,y,z))
+   #define GLScalef(x, y, z)              (glCaps_fixedFunction ? glScalef(x, y, z) : glmsScaled(x,y,z))
+   #define GLTranslated(x, y, z)          (glCaps_fixedFunction ? glTranslated(x,y,z) : glmsTranslated(x,y,z))
+   #define GLRotated(a, x, y, z)          (glCaps_fixedFunction ? glRotated(a, x,y,z) : glmsRotated(a,x,y,z))
+   #define GLMatrixMode(m)                (glCaps_fixedFunction ? glMatrixMode(m) : glmsMatrixMode(m))
+   #define GLLoadIdentity()               (glCaps_fixedFunction ? glLoadIdentity() : glmsLoadIdentity())
+   #define GLPushMatrix()                 (glCaps_fixedFunction ? glPushMatrix() : glmsPushMatrix())
+   #define GLPopMatrix()                  (glCaps_fixedFunction ? glPopMatrix() : glmsPopMatrix())
+   #define GLFlushMatrices()              (glCaps_fixedFunction ? (void)0 : glmsFlushMatrices())
    #define GLLoadMatrix(m)                (glmsLoadMatrix(m), glmsFlushMatrices())
 #elif ENABLE_GL_INTDBL
    #define GLLoadMatrixd                  glLoadMatrixd
 #endif
 
 #if ENABLE_GL_LEGACY
-   #define GLRecti(x1, y1, x2, y2)           (glcaps_immediate ? glRecti(x1, y1, x2, y2) : glimtkRecti(x1, y1, x2, y2))
-   #define GLBegin(m)                        (glcaps_immediate ? glBegin(m) : glimtkBegin(m))
-   #define GLEnd()                           (glcaps_immediate ? glEnd() : glimtkEnd())
-   #define GLVertex2i(x,y)                   (glcaps_immediate ? glVertex2i(x,y) : glimtkVertex2i(x,y))
-   #define GLVertex2f(x,y)                   (glcaps_immediate ? glVertex2f(x,y) : glimtkVertex2f(x,y))
-   #define GLVertex2d(x,y)                   (glcaps_immediate ? glVertex2d(x,y) : glimtkVertex2d(x,y))
-   #define GLVertex3f(x,y,z)                 (glcaps_immediate ? glVertex3f(x,y,z) : glimtkVertex3f(x,y,z))
-   #define GLVertex3d(x,y,z)                 (glcaps_immediate ? glVertex3d(x,y,z) : glimtkVertex3d(x,y,z))
-   #define GLVertex3fv(v)                    (glcaps_immediate ? glVertex3fv(v) : glimtkVertex3fv(v))
-   #define GLVertex3dv(v)                    (glcaps_immediate ? glVertex3dv(v) : glimtkVertex3dv(v))
-   #define GLTexCoord2i(x,y)                 (glcaps_immediate ? glTexCoord2i(x,y) : glimtkTexCoord2i(x,y))
-   #define GLTexCoord2f(x,y)                 (glcaps_immediate ? glTexCoord2f(x,y) : glimtkTexCoord2f(x,y))
-   #define GLTexCoord2d(x,y)                 (glcaps_immediate ? glTexCoord2d(x,y) : glimtkTexCoord2d(x,y))
-   #define GLTexCoord2fv(v)                  (glcaps_immediate ? glTexCoord2fv(v) : glimtkTexCoord2fv(v))
-   #define GLNormal3f(x,y,z)                 (glcaps_immediate ? glNormal3f : glimtkNormal3f)
-   #define GLNormal3d(x,y,z)                 (glcaps_immediate ? glNormal3d : glimtkNormal3d)
-   #define GLNormal3fv(v)                    (glcaps_immediate ? glNormal3fv(v) : glimtkNormal3fv(v))
-   #define GLNormal3dv(v)                    (glcaps_immediate ? glNormal3dv(v) : glimtkNormal3dv(v))
-   #define GLColor3f(a,b,c)                  (glcaps_immediate ? glColor3f(a,b,c) : glimtkColor3f(a,b,c))
-   #define GLColor4ub(a,b,c,d)               (glcaps_immediate ? glColor4ub(a,b,c,d) : glimtkColor4ub(a,b,c,d))
-   #define GLColor4f(a,b,c,d)                (glcaps_immediate ? glColor4f(a,b,c,d) : glimtkColor4f(a,b,c,d))
-   #define GLColor4fv(v)                     (glcaps_immediate ? glColor4fv(v) : glimtkColor4fv(v))
+   #define GLRecti(x1, y1, x2, y2)           (glCaps_immediate ? glRecti(x1, y1, x2, y2) : glimtkRecti(x1, y1, x2, y2))
+   #define GLBegin(m)                        (glCaps_immediate ? glBegin(m) : glimtkBegin(m))
+   #define GLEnd()                           (glCaps_immediate ? glEnd() : glimtkEnd())
+   #define GLVertex2i(x,y)                   (glCaps_immediate ? glVertex2i(x,y) : glimtkVertex2i(x,y))
+   #define GLVertex2f(x,y)                   (glCaps_immediate ? glVertex2f(x,y) : glimtkVertex2f(x,y))
+   #define GLVertex2d(x,y)                   (glCaps_immediate ? glVertex2d(x,y) : glimtkVertex2d(x,y))
+   #define GLVertex3f(x,y,z)                 (glCaps_immediate ? glVertex3f(x,y,z) : glimtkVertex3f(x,y,z))
+   #define GLVertex3d(x,y,z)                 (glCaps_immediate ? glVertex3d(x,y,z) : glimtkVertex3d(x,y,z))
+   #define GLVertex3fv(v)                    (glCaps_immediate ? glVertex3fv(v) : glimtkVertex3fv(v))
+   #define GLVertex3dv(v)                    (glCaps_immediate ? glVertex3dv(v) : glimtkVertex3dv(v))
+   #define GLTexCoord2i(x,y)                 (glCaps_immediate ? glTexCoord2i(x,y) : glimtkTexCoord2i(x,y))
+   #define GLTexCoord2f(x,y)                 (glCaps_immediate ? glTexCoord2f(x,y) : glimtkTexCoord2f(x,y))
+   #define GLTexCoord2d(x,y)                 (glCaps_immediate ? glTexCoord2d(x,y) : glimtkTexCoord2d(x,y))
+   #define GLTexCoord2fv(v)                  (glCaps_immediate ? glTexCoord2fv(v) : glimtkTexCoord2fv(v))
+   #define GLNormal3f(x,y,z)                 (glCaps_immediate ? glNormal3f : glimtkNormal3f)
+   #define GLNormal3d(x,y,z)                 (glCaps_immediate ? glNormal3d : glimtkNormal3d)
+   #define GLNormal3fv(v)                    (glCaps_immediate ? glNormal3fv(v) : glimtkNormal3fv(v))
+   #define GLNormal3dv(v)                    (glCaps_immediate ? glNormal3dv(v) : glimtkNormal3dv(v))
+   #define GLColor3f(a,b,c)                  (glCaps_immediate ? glColor3f(a,b,c) : glimtkColor3f(a,b,c))
+   #define GLColor4ub(a,b,c,d)               (glCaps_immediate ? glColor4ub(a,b,c,d) : glimtkColor4ub(a,b,c,d))
+   #define GLColor4f(a,b,c,d)                (glCaps_immediate ? glColor4f(a,b,c,d) : glimtkColor4f(a,b,c,d))
+   #define GLColor4fv(v)                     (glCaps_immediate ? glColor4fv(v) : glimtkColor4fv(v))
 #else
    #define GLRecti                           glimtkRecti
    #define GLBegin                           glimtkBegin
 #endif
 
 #define SETCAPS(caps) \
-   glcaps                     = caps; \
-   glcaps_shaders             = glcaps.shaders; \
-   glcaps_fixedFunction       = glcaps.fixedFunction; \
-   glcaps_nonPow2Textures     = glcaps.nonPow2Textures; \
-   glcaps_vertexBuffer        = glcaps.vertexBuffer; \
-   glcaps_quads               = glcaps.quads; \
-   glcaps_intAndDouble        = glcaps.intAndDouble; \
-   glcaps_immediate           = glcaps.immediate; \
-   glcaps_legacy              = glcaps.legacy; \
-   glcaps_pointSize           = glcaps.pointSize; \
-   glcaps_frameBuffer         = glcaps.frameBuffer;
+   glCaps                     = caps; \
+   glCaps_shaders             = glCaps.shaders; \
+   glCaps_fixedFunction       = glCaps.fixedFunction; \
+   glCaps_nonPow2Textures     = glCaps.nonPow2Textures; \
+   glCaps_vertexBuffer        = glCaps.vertexBuffer; \
+   glCaps_quads               = glCaps.quads; \
+   glCaps_intAndDouble        = glCaps.intAndDouble; \
+   glCaps_immediate           = glCaps.immediate; \
+   glCaps_legacy              = glCaps.legacy; \
+   glCaps_legacyFormats       = glCaps.legacyFormats; \
+   glCaps_pointSize           = glCaps.pointSize; \
+   glCaps_frameBuffer         = glCaps.frameBuffer; \
+   glCaps_vao                 = glCaps.vao; \
+   glCaps_compatible          = glCaps.compatible; \
+   glCaps_select              = glCaps.select; \
+   glCaps_vertexPointer       = glCaps.vertexPointer
 
-extern GLCapabilities glcaps;
-extern bool glcaps_nonPow2Textures, glcaps_vertexBuffer, glcaps_quads, glcaps_intAndDouble;
-extern bool glcaps_shaders, glcaps_fixedFunction, glcaps_immediate, glcaps_legacy, glcaps_pointSize, glcaps_frameBuffer;
+extern GLCapabilities glCaps;
+extern bool glCaps_nonPow2Textures, glCaps_vertexBuffer, glCaps_quads, glCaps_intAndDouble, glCaps_legacyFormats, glCaps_compatible, glCaps_vertexPointer;
+extern bool glCaps_shaders, glCaps_fixedFunction, glCaps_immediate, glCaps_legacy, glCaps_pointSize, glCaps_frameBuffer, glCaps_vao, glCaps_select;
 
 #if ENABLE_GL_INTDBL
    #define GL_INDEX_INT GL_UNSIGNED_INT
index ff3bd6b..84a0d24 100644 (file)
@@ -9,7 +9,7 @@ import "OpenGLDisplayDriver"
 
 public void GLABDeleteBuffers(int count, GLAB * buffers)
 {
-   if(glcaps_vertexBuffer)
+   if(glCaps_vertexBuffer)
    {
       int i;
       for(i = 0; i < count; i++)
@@ -31,7 +31,7 @@ public void GLABDeleteBuffers(int count, GLAB * buffers)
 // NOTE: Don't call if without vertexBuffer
 void GLABBindBuffer(int target, uint buffer)
 {
-   if(glcaps_vertexBuffer)
+   if(glCaps_vertexBuffer)
    {
       glBindBuffer(target, buffer);
       if(target == GL_ARRAY_BUFFER)
@@ -45,7 +45,7 @@ public enum GLBufferContents { vertex, normal, texCoord, color };
 
 public enum GLBufferUsage { staticDraw, dynamicDraw, streamDraw };
 
-static GLint bufferUsages[] = { GL_DYNAMIC_DRAW, GL_STATIC_DRAW, GL_STREAM_DRAW };
+static GLint bufferUsages[] = { GL_DYNAMIC_DRAW, GL_STATIC_DRAW, 0x88E0 /*GL_STREAM_DRAW*/ };
 
 public define noAB = GLAB { 0 };
 
@@ -68,7 +68,7 @@ public struct GLAB
    {
       if(this != null)
       {
-         if(glcaps_vertexBuffer)
+         if(glCaps_vertexBuffer)
          {
             if(!buffer)
                glGenBuffers(1, &buffer);
@@ -83,7 +83,7 @@ public struct GLAB
 
    void upload(uint offset, uint size, void * data)
    {
-      if(this != null && glcaps_vertexBuffer)
+      if(this != null && glCaps_vertexBuffer)
       {
          if(glabCurArrayBuffer != buffer)
             GLABBindBuffer(GL_ARRAY_BUFFER, buffer);
@@ -95,7 +95,7 @@ public struct GLAB
    {
       if(this != null && buffer)
       {
-         if(glcaps_vertexBuffer)
+         if(glCaps_vertexBuffer)
             GLABDeleteBuffers(1, this);
          buffer = 0;
       }
@@ -103,15 +103,15 @@ public struct GLAB
 
    void use(GLBufferContents contents, int n, int type, uint stride, void * pointer)
    {
-      if(glabCurArrayBuffer != ((this != null) ? buffer : 0) && glcaps_vertexBuffer)
+      if(glabCurArrayBuffer != ((this != null) ? buffer : 0) && glCaps_vertexBuffer)
          GLABBindBuffer(GL_ARRAY_BUFFER, ((this != null) ? buffer : 0));
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
          glVertexAttribPointer(contents, n, type, GL_FALSE, stride, pointer);
 #endif
 
 #if ENABLE_GL_FFP
-      if(!glcaps_shaders)
+      if(!glCaps_shaders)
          switch(contents)
          {
             case normal:   glNormalPointer      (type, stride, pointer); break;
@@ -124,42 +124,43 @@ public struct GLAB
 
    void useVertTrans(uint count, int n, int type, uint stride, void * pointer)
    {
-#if !ENABLE_GL_INTDBL
-      if(glabCurArrayBuffer != ((this != null) ? buffer : 0) && glcaps_vertexBuffer)
-         GLABBindBuffer(GL_ARRAY_BUFFER, ((this != null) ? buffer : 0));
-      if(type == GL_INT)
+      if(!glCaps_intAndDouble)
       {
-         if(pointer)
+         if(glabCurArrayBuffer != ((this != null) ? buffer : 0) && glCaps_vertexBuffer)
+            GLABBindBuffer(GL_ARRAY_BUFFER, ((this != null) ? buffer : 0));
+         if(type == GL_INT)
          {
-            int i;
-            if(count*n > shortVPSize)
+            if(pointer)
             {
-               shortVPSize = count*n;
-               shortVPBuffer = renew shortVPBuffer short[shortVPSize];
+               int i;
+               if(count*n > shortVPSize)
+               {
+                  shortVPSize = count*n;
+                  shortVPBuffer = renew shortVPBuffer short[shortVPSize];
+               }
+               for(i = 0; i < count*n; i++)
+                  shortVPBuffer[i] = (short)((int *)pointer)[i];
+
+               GLVertexPointer(n, GL_SHORT, stride, shortVPBuffer);
             }
-            for(i = 0; i < count*n; i++)
-               shortVPBuffer[i] = (short)pointer[i];
-
-            GLVertexPointer(n, GL_SHORT, stride, shortVPBuffer);
+            else
+               GLVertexPointer(n, GL_SHORT, stride, 0);
+         }
+         else if(type == GL_DOUBLE)
+         {
+   #if ENABLE_GL_SHADERS
+            if(glCaps_shaders)
+               glVertexAttribPointer(GLBufferContents::vertex, n, GL_DOUBLE, GL_FALSE, stride, pointer);
+   #endif
+
+   #if ENABLE_GL_FFP
+            if(!glCaps_shaders)
+               glVertexPointer(n, GL_DOUBLE, stride, pointer);
+   #endif
          }
-         else
-            GLVertexPointer(n, GL_SHORT, stride, 0);
-      }
-      else if(type == GL_DOUBLE)
-      {
-#if ENABLE_GL_SHADERS
-         if(glcaps_shaders)
-            glVertexAttribPointer(GLBufferContents::vertex, n, GL_DOUBLE, GL_FALSE, stride, pointer);
-#endif
-
-#if ENABLE_GL_FFP
-         if(!glcaps_shaders)
-            glVertexPointer(n, GL_DOUBLE, stride, pointer);
-#endif
       }
-#else
-      use(vertex, n, type, stride, pointer);
-#endif
+      else
+         use(vertex, n, type, stride, pointer);
    }
 };
 
@@ -175,12 +176,12 @@ public struct GLEAB
    {
       if(this != null)
       {
-         if(glcaps_vertexBuffer)
+         if(glCaps_vertexBuffer)
          {
             if(!buffer)
                glGenBuffers(1, &buffer);
 
-            if(glcaps_vertexBuffer && glabCurElementBuffer != buffer)
+            if(glCaps_vertexBuffer && glabCurElementBuffer != buffer)
                GLABBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
             if(size)
                glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data, bufferUsages[usage]);
@@ -194,7 +195,7 @@ public struct GLEAB
 
    void upload(uint offset, uint size, void * data)
    {
-      if(this != null && glcaps_vertexBuffer)
+      if(this != null && glCaps_vertexBuffer)
       {
          if(glabCurArrayBuffer != buffer)
             GLABBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
@@ -206,7 +207,7 @@ public struct GLEAB
    {
       if(this != null && buffer)
       {
-         if(glcaps_vertexBuffer)
+         if(glCaps_vertexBuffer)
             GLABDeleteBuffers(1, (GLAB *)this);
          buffer = 0;
       }
@@ -214,17 +215,16 @@ public struct GLEAB
 
    void draw(int primType, int count, int type, void * indices)
    {
-      if(glcaps_vertexBuffer
+      if(glCaps_vertexBuffer
 #if ENABLE_GL_POINTER
-         || (!buffer && indices)
+         || (glCaps_vertexPointer && !buffer && indices)
 #endif
          )
       {
-         if(glcaps_vertexBuffer && glabCurElementBuffer != ((this != null) ? buffer : 0))
+         if(glCaps_vertexBuffer && glabCurElementBuffer != ((this != null) ? buffer : 0))
             GLABBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ((this != null) ? buffer : 0));
-#if !ENABLE_GL_INTDBL
-         type = GL_UNSIGNED_SHORT;
-#endif
+         if(!glCaps_intAndDouble)
+            type = GL_UNSIGNED_SHORT;
          GLFlushMatrices();
          glDrawElements(primType, count, type, indices);
       }
index e856028..fb5e7b1 100644 (file)
@@ -98,7 +98,7 @@ public void glimtkBegin(GLIMTKMode mode)
 public void glimtkTexCoord2f(float x, float y)
 {
    int stride = verticesBuf.stride;
-   bool quadsAdd = beginMode == quads && !glcaps_quads && ((beginCount % 4) == 3);
+   bool quadsAdd = beginMode == quads && !glCaps_quads && ((beginCount % 4) == 3);
    float * buf = verticesBuf.ensure(quadsAdd ? 3 : 1);
    buf[0] = x;
    buf[1] = y;
@@ -124,7 +124,7 @@ public void glimtkVertex2f(float x, float y)
    verticesBuf.stride = vertexOffset + numCoords;
    {
       int stride = verticesBuf.stride;
-      bool quadsAdd = beginMode == quads && !glcaps_quads && ((beginCount % 4) == 3);
+      bool quadsAdd = beginMode == quads && !glCaps_quads && ((beginCount % 4) == 3);
       float * buf = verticesBuf.ensure(quadsAdd ? 3 : 1) + vertexOffset;
       buf[0] = x;
       buf[1] = y;
@@ -151,7 +151,7 @@ public void glimtkVertex3f( float x, float y, float z )
    verticesBuf.stride = vertexOffset + numCoords;
    {
       int stride = verticesBuf.stride;
-      bool quadsAdd = beginMode == quads && !glcaps_quads && ((beginCount % 4) == 3);
+      bool quadsAdd = beginMode == quads && !glCaps_quads && ((beginCount % 4) == 3);
       float * buf = verticesBuf.ensure(quadsAdd ? 3 : 1) + vertexOffset;
       buf[0] = x;
       buf[1] = y;
@@ -187,7 +187,7 @@ public void glimtkColor4f(float r, float g, float b, float a)
       verticesBuf.stride = vertexOffset + numCoords;
       {
          int stride = verticesBuf.stride;
-         bool quadsAdd = beginMode == quads && !glcaps_quads && ((beginCount % 4) == 3);
+         bool quadsAdd = beginMode == quads && !glCaps_quads && ((beginCount % 4) == 3);
          float * buf = verticesBuf.ensure(quadsAdd ? 3 : 1) + 2;
          buf[0] = r, buf[1] = g, buf[2] = b, buf[3] = a;
 
@@ -209,12 +209,12 @@ public void glimtkColor4f(float r, float g, float b, float a)
    else
    {
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
          shader_color(r, g, b, a);
 #endif
 
 #if ENABLE_GL_FFP
-      if(!glcaps_shaders)
+      if(!glCaps_shaders)
       {
          glColor4f(r, g, b, a);
          if(lightingEnabled)
@@ -238,7 +238,7 @@ public void glimtkNormal3f(float x, float y, float z)
    normalsBuf.count = verticesBuf.count;
    {
       int stride = normalsBuf.stride;
-      bool quadsAdd = beginMode == quads && !glcaps_quads && ((beginCount % 4) == 3);
+      bool quadsAdd = beginMode == quads && !glCaps_quads && ((beginCount % 4) == 3);
       float * buf = normalsBuf.ensure(quadsAdd ? 3 : 1) + 2;
 
       buf[0] = x, buf[1] = y, buf[2] = z;
@@ -265,7 +265,7 @@ public void glimtkNormal3fd(double * coords)                     { glimtkNormal3
 public void glimtkEnd()
 {
    GLIMTKMode mode = beginMode;
-   if(!glcaps_quads)
+   if(!glCaps_quads)
    {
       if(mode == quads)        mode = triangles;
       else if(mode == polygon) mode = triangleFan;
@@ -273,7 +273,7 @@ public void glimtkEnd()
 
    GLEnableClientState(TEXCOORDS);
 
-   if(glcaps_vertexBuffer)
+   if(glCaps_vertexBuffer)
    {
       verticesBuf.upload();
       verticesBuf.use(texCoord, 2, GL_FLOAT, verticesBuf.stride * sizeof(float), 0);
@@ -284,18 +284,18 @@ public void glimtkEnd()
    if(vertexColorValues)
    {
       GLEnableClientState(COLORS);
-      if(glcaps_vertexBuffer)
+      if(glCaps_vertexBuffer)
          verticesBuf.use(color, 4, GL_FLOAT, verticesBuf.stride * sizeof(float), (void *)(2 * sizeof(float)));
       else
          noAB.use(color, 4, GL_FLOAT, verticesBuf.stride * sizeof(float), verticesBuf.pointer + 2);
 
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
          shader_setPerVertexColor(true);
 #endif
    }
 
-   if(glcaps_vertexBuffer)
+   if(glCaps_vertexBuffer)
       verticesBuf.use(vertex, numCoords, GL_FLOAT, verticesBuf.stride * sizeof(float), (void *)(vertexOffset * sizeof(float)));
    else
       noAB.use(vertex, numCoords, GL_FLOAT, verticesBuf.stride * sizeof(float), verticesBuf.pointer + vertexOffset);
@@ -303,7 +303,7 @@ public void glimtkEnd()
    if(normalsBuf.count && normalsBuf.count == verticesBuf.count)
    {
       GLEnableClientState(NORMALS);
-      if(glcaps_vertexBuffer)
+      if(glCaps_vertexBuffer)
       {
          normalsBuf.upload();
          normalsBuf.use(normal, 3, GL_FLOAT, 3*sizeof(float), 0);
@@ -322,7 +322,7 @@ public void glimtkEnd()
       GLDisableClientState(COLORS);
 
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders)
+      if(glCaps_shaders)
          shader_setPerVertexColor(false);
 #endif
 
index 413b851..a8344b5 100644 (file)
@@ -267,7 +267,7 @@ public void glmsFlushMatrices()
       {
          Matrix * matrix = &matrixStack[stack][matrixIndex[stack]];
 #if ENABLE_GL_SHADERS
-         if(glcaps_shaders)
+         if(glCaps_shaders)
          {
             if(stack == 0)
             {
@@ -307,7 +307,7 @@ public void glmsFlushMatrices()
 #endif
 
 #if ENABLE_GL_FFP
-         if(!glcaps_shaders)
+         if(!glCaps_shaders)
          {
             float m[16] =
             {
@@ -323,7 +323,7 @@ public void glmsFlushMatrices()
          stackModified[stack] = false;
       }
 #if ENABLE_GL_SHADERS
-      if(glcaps_shaders && stack == 1 && prjViewModified)
+      if(glCaps_shaders && stack == 1 && prjViewModified)
       {
          Matrix * mv = &matrixStack[0][matrixIndex[0]];
          Matrix * prj = &matrixStack[1][matrixIndex[1]];
index c41433f..eb23962 100644 (file)
@@ -4997,7 +4997,7 @@ private:
 
          if(!displaySystem)
          {
-            displaySystem = DisplaySystem {};
+            displaySystem = DisplaySystem { glCapabilities = glCapabilities };
             if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
             {
                delete displaySystem;
@@ -9647,6 +9647,10 @@ public:
             (glCapabilities.nonPow2Textures != value.nonPow2Textures ||
              glCapabilities.intAndDouble != value.intAndDouble ||
              glCapabilities.vertexBuffer != value.vertexBuffer ||
+             glCapabilities.compatible != value.compatible ||
+             glCapabilities.legacyFormats != value.legacyFormats ||
+             glCapabilities.debug != value.debug ||
+             glCapabilities.vertexPointer != value.vertexPointer ||
              glCapabilities.quads != value.quads);
          if(reload)
             UnloadGraphics(false);
@@ -9811,7 +9815,7 @@ private:
    void * windowData;
    CreationActivationOption creationActivation;
    GLCapabilities glCapabilities;
-   glCapabilities = { true, true, true, true, true, true, true, true, true, true };
+   glCapabilities = { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true };
    struct
    {
       bool active:1;            // true if window and ancestors are active