Work-around for an issue which cropped up with the release of gcc-10. In their
[freeglut] / src / fg_gl2.h
index 54076d7..fb3d467 100644 (file)
 #ifndef  FG_GL2_H
 #define  FG_GL2_H
 
-#ifndef APIENTRY
-#    define APIENTRY
-#endif
+#include <GL/freeglut.h>
+#include "fg_internal.h"
+
+#ifdef GL_ES_VERSION_2_0
+/* Use existing functions on GLES 2.0 */
+
+#define FGH_ARRAY_BUFFER GL_ARRAY_BUFFER
+#define FGH_STATIC_DRAW GL_STATIC_DRAW
+#define FGH_ELEMENT_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER
+
+#define fghGenBuffers glGenBuffers
+#define fghDeleteBuffers glDeleteBuffers
+#define fghBindBuffer glBindBuffer
+#define fghBufferData glBufferData
+#define fghEnableVertexAttribArray glEnableVertexAttribArray
+#define fghDisableVertexAttribArray glDisableVertexAttribArray
+#define fghVertexAttribPointer glVertexAttribPointer
+
+#else
+/* Load functions dynamically, they are not defined in e.g. win32's
+   OpenGL headers */
+
+#    ifndef APIENTRY
+#        define APIENTRY
+#    endif
 
 /* extension #defines, types and entries, avoiding a dependency on additional
    libraries like GLEW or the GL/glext.h header */
@@ -45,12 +67,16 @@ typedef void (APIENTRY *FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
 typedef void (APIENTRY *FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
 typedef void (APIENTRY *FGH_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
 
-FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
-FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
-FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
-FGH_PFNGLBUFFERDATAPROC fghBufferData;
-FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
-FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
-FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+extern FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
+extern FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
+extern FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
+extern FGH_PFNGLBUFFERDATAPROC fghBufferData;
+extern FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
+extern FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
+extern FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+
+#    endif
+
+extern void fgInitGL2();
 
 #endif