Work-around for an issue which cropped up with the release of gcc-10. In their
[freeglut] / src / fg_gl2.c
index 9e31502..54b4285 100644 (file)
 #include "fg_internal.h"
 #include "fg_gl2.h"
 
+#ifndef GL_ES_VERSION_2_0
+/* GLES2 has the corresponding entry points built-in, and these fgh-prefixed
+ * names are defined in fg_gl2.h header to reference them, for any other case,
+ * define them as function pointers here.
+ */
+FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
+FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
+FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
+FGH_PFNGLBUFFERDATAPROC fghBufferData;
+FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
+FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
+FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+#endif
+
 void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib) {
   if (fgStructure.CurrentWindow != NULL)
     fgStructure.CurrentWindow->Window.attribute_v_coord = attrib;
@@ -37,18 +51,26 @@ void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib) {
     fgStructure.CurrentWindow->Window.attribute_v_normal = attrib;
 }
 
+void FGAPIENTRY glutSetVertexAttribTexCoord2(GLint attrib) {
+    if (fgStructure.CurrentWindow != NULL)
+        fgStructure.CurrentWindow->Window.attribute_v_texture = attrib;
+}
+
 void fgInitGL2() {
-    fgState.HasOpenGL20 = 0;
-    // TODO: Mesa returns a valid stub function, rather than NULL,
-    // when we request a non-existent function
+#ifdef GL_ES_VERSION_2_0
+    fgState.HasOpenGL20 = (fgState.MajorVersion >= 2);
+#else
+    /* TODO: Mesa returns a valid stub function, rather than NULL,
+       when we request a non-existent function */
 #define CHECK(func, a) if ((a) == NULL) { fgWarning("fgInitGL2: " func " is NULL"); return; }
-    CHECK("fghGenBuffers", fghGenBuffers = (FGH_PFNGLGENBUFFERSPROC) glutGetProcAddress ("glGenBuffers"));
-    CHECK("fghDeleteBuffers", fghDeleteBuffers = (FGH_PFNGLDELETEBUFFERSPROC) glutGetProcAddress ("glDeleteBuffers"));
-    CHECK("fghBindBuffer", fghBindBuffer = (FGH_PFNGLBINDBUFFERPROC) glutGetProcAddress ("glBindBuffer"));
-    CHECK("fghBufferData", fghBufferData = (FGH_PFNGLBUFFERDATAPROC) glutGetProcAddress ("glBufferData"));
-    CHECK("fghVertexAttribPointer", fghVertexAttribPointer = (FGH_PFNGLVERTEXATTRIBPOINTERPROC) glutGetProcAddress ("glVertexAttribPointer"));
-    CHECK("fghEnableVertexAttribArray", fghEnableVertexAttribArray = (FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress ("glEnableVertexAttribArray"));
-    CHECK("fghDisableVertexAttribArray", fghDisableVertexAttribArray = (FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress ("glDisableVertexAttribArray"));
+    CHECK("fghGenBuffers", fghGenBuffers = (FGH_PFNGLGENBUFFERSPROC)glutGetProcAddress("glGenBuffers"));
+    CHECK("fghDeleteBuffers", fghDeleteBuffers = (FGH_PFNGLDELETEBUFFERSPROC)glutGetProcAddress("glDeleteBuffers"));
+    CHECK("fghBindBuffer", fghBindBuffer = (FGH_PFNGLBINDBUFFERPROC)glutGetProcAddress("glBindBuffer"));
+    CHECK("fghBufferData", fghBufferData = (FGH_PFNGLBUFFERDATAPROC)glutGetProcAddress("glBufferData"));
+    CHECK("fghVertexAttribPointer", fghVertexAttribPointer = (FGH_PFNGLVERTEXATTRIBPOINTERPROC)glutGetProcAddress("glVertexAttribPointer"));
+    CHECK("fghEnableVertexAttribArray", fghEnableVertexAttribArray = (FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC)glutGetProcAddress("glEnableVertexAttribArray"));
+    CHECK("fghDisableVertexAttribArray", fghDisableVertexAttribArray = (FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC)glutGetProcAddress("glDisableVertexAttribArray"));
 #undef CHECK
     fgState.HasOpenGL20 = 1;
+#endif
 }