summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-30 13:38:28 +0100
committerwm4 <wm4@nowhere>2019-11-30 13:38:28 +0100
commitfa9a1ff0a0f2ec0c37e27c30ad71ba814c7ada89 (patch)
tree5ab9d300f8271ff3ace20786f2e478e6342bdc07
parent8614cb38d9f708c785bc4ffefb87673b4dd43564 (diff)
downloadmpv-fa9a1ff0a0f2ec0c37e27c30ad71ba814c7ada89.tar.bz2
mpv-fa9a1ff0a0f2ec0c37e27c30ad71ba814c7ada89.tar.xz
vo_gpu: opengl: add hack for ancient Mesa/GLX
glx.h recursively includes gl.h, and there is no way to prevent this. Old Mesa defines some GL symbols, but not all which mpv needs. In particular, one user who was too lazy to update his ancient Ubuntu and preferred to bother us with obscure bug reports, had Mesa headers which did not define GL 3.2, so GLsync was not defined. All in all I still think the idea of providing the GL API definitions ourselves was a good idea; just GLX should have been isolated better. But isolating GLX now is too much effort. Not sure why I'm bothering with this at all. Fixes: #7201 (unconfirmed)
-rw-r--r--video/out/opengl/gl_headers.h70
1 files changed, 47 insertions, 23 deletions
diff --git a/video/out/opengl/gl_headers.h b/video/out/opengl/gl_headers.h
index 609cf53ff2..ad276b3c7b 100644
--- a/video/out/opengl/gl_headers.h
+++ b/video/out/opengl/gl_headers.h
@@ -28,6 +28,53 @@
#endif
#endif
+// Typedefs. This needs to work with system headers too (consider GLX), and
+// before C11, duplicated typedefs were an error. So try to tolerate at least
+// Mesa.
+#ifdef GL_TRUE
+ // Tolerate old Mesa which has only definitions up to GL 2.0.
+ #define MP_GET_GL_TYPES_2_0 0
+ #ifdef GL_VERSION_3_2
+ #define MP_GET_GL_TYPES_3_2 0
+ #else
+ #define MP_GET_GL_TYPES_3_2 1
+ #endif
+#else
+ // Get them all.
+ #define MP_GET_GL_TYPES_2_0 1
+ #define MP_GET_GL_TYPES_3_2 1
+#endif
+
+#if MP_GET_GL_TYPES_2_0
+// GL_VERSION_1_0, GL_ES_VERSION_2_0
+typedef unsigned int GLbitfield;
+typedef unsigned char GLboolean;
+typedef unsigned int GLenum;
+typedef float GLfloat;
+typedef int GLint;
+typedef int GLsizei;
+typedef uint8_t GLubyte;
+typedef unsigned int GLuint;
+typedef void GLvoid;
+// GL 1.1 GL_VERSION_1_1, GL_ES_VERSION_2_0
+typedef float GLclampf;
+// GL 1.5 GL_VERSION_1_5, GL_ES_VERSION_2_0
+typedef intptr_t GLintptr;
+typedef ptrdiff_t GLsizeiptr;
+// GL 2.0 GL_VERSION_2_0, GL_ES_VERSION_2_0
+typedef int8_t GLbyte;
+typedef char GLchar;
+typedef short GLshort;
+typedef unsigned short GLushort;
+#endif
+
+#if MP_GET_GL_TYPES_3_2
+// GL 3.2 GL_VERSION_3_2, GL_ES_VERSION_2_0
+typedef int64_t GLint64;
+typedef struct __GLsync *GLsync;
+typedef uint64_t GLuint64;
+#endif
+
// --- GL 1.1
#define GL_BACK_LEFT 0x0402
@@ -118,29 +165,6 @@
// ---- GLES 2
-#ifndef GL_TRUE
-typedef int8_t GLbyte;
-typedef float GLclampf;
-typedef int32_t GLfixed;
-typedef short GLshort;
-typedef unsigned short GLushort;
-typedef void GLvoid;
-typedef struct __GLsync *GLsync;
-typedef int64_t GLint64;
-typedef uint64_t GLuint64;
-typedef unsigned int GLenum;
-typedef unsigned int GLuint;
-typedef char GLchar;
-typedef float GLfloat;
-typedef ptrdiff_t GLsizeiptr;
-typedef intptr_t GLintptr;
-typedef unsigned int GLbitfield;
-typedef int GLint;
-typedef unsigned char GLboolean;
-typedef int GLsizei;
-typedef uint8_t GLubyte;
-#endif
-
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000