[vlc-commits] gl: fix core functions loading on Windows

Thomas Guillem git at videolan.org
Thu Aug 31 11:27:54 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Aug 31 11:25:39 2017 +0200| [b1f85289a6b0c07874cfe64daae6b75cbcc6b972] | committer: Thomas Guillem

gl: fix core functions loading on Windows

Don't use vlc_gl_GetProcAddress() to fetch GL core functions.
It was working on other OSses than Windows since dlsym() was used.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b1f85289a6b0c07874cfe64daae6b75cbcc6b972
---

 modules/video_output/opengl/converter.h   | 71 +++++++++++++++++--------------
 modules/video_output/opengl/vout_helper.c | 36 ++++++++--------
 2 files changed, 58 insertions(+), 49 deletions(-)

diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index 7ca1a2e262..5f4d0493d8 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -99,53 +99,60 @@ typedef GLenum (*PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint
  * Structure containing function pointers to shaders commands
  */
 typedef struct {
-    /* Utils commands */
+    /*
+     * GL / GLES core functions
+     */
     PFNGLGETERRORPROC       GetError;
     PFNGLGETSTRINGPROC      GetString;
     PFNGLGETINTEGERVPROC    GetIntegerv;
+    PFNGLBINDTEXTUREPROC    BindTexture;
+    PFNGLTEXPARAMETERIPROC  TexParameteri;
+    PFNGLTEXPARAMETERFPROC  TexParameterf;
+    PFNGLPIXELSTOREIPROC    PixelStorei;
+    PFNGLGENTEXTURESPROC    GenTextures;
+    PFNGLDELETETEXTURESPROC DeleteTextures;
+    PFNGLTEXIMAGE2DPROC     TexImage2D;
+    PFNGLTEXSUBIMAGE2DPROC  TexSubImage2D;
+
+    /* GL only core functions: NULL for GLES2 */
+    PFNGLGETTEXLEVELPARAMETERIVPROC GetTexLevelParameteriv; /* Can be NULL */
+
+    /*
+     * GL / GLES extensions
+     */
+
+    /* Shader commands */
+    PFNGLCREATESHADERPROC   CreateShader;
+    PFNGLSHADERSOURCEPROC   ShaderSource;
+    PFNGLCOMPILESHADERPROC  CompileShader;
+    PFNGLATTACHSHADERPROC   AttachShader;
+    PFNGLDELETESHADERPROC   DeleteShader;
 
-    /* Shader variables commands*/
+    /* Shader log commands */
+    PFNGLGETPROGRAMIVPROC       GetProgramiv;
+    PFNGLGETSHADERIVPROC        GetShaderiv;
+    PFNGLGETPROGRAMINFOLOGPROC  GetProgramInfoLog;
+    PFNGLGETSHADERINFOLOGPROC   GetShaderInfoLog;
+
+    /* Shader variables commands */
     PFNGLGETUNIFORMLOCATIONPROC      GetUniformLocation;
     PFNGLGETATTRIBLOCATIONPROC       GetAttribLocation;
     PFNGLVERTEXATTRIBPOINTERPROC     VertexAttribPointer;
     PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
+    PFNGLUNIFORMMATRIX4FVPROC        UniformMatrix4fv;
+    PFNGLUNIFORM4FVPROC              Uniform4fv;
+    PFNGLUNIFORM4FPROC               Uniform4f;
+    PFNGLUNIFORM2FPROC               Uniform2f;
+    PFNGLUNIFORM1IPROC               Uniform1i;
 
-    PFNGLUNIFORMMATRIX4FVPROC   UniformMatrix4fv;
-    PFNGLUNIFORM4FVPROC         Uniform4fv;
-    PFNGLUNIFORM4FPROC          Uniform4f;
-    PFNGLUNIFORM2FPROC          Uniform2f;
-    PFNGLUNIFORM1IPROC          Uniform1i;
-
-    /* Shader command */
-    PFNGLCREATESHADERPROC CreateShader;
-    PFNGLSHADERSOURCEPROC ShaderSource;
-    PFNGLCOMPILESHADERPROC CompileShader;
-    PFNGLDELETESHADERPROC   DeleteShader;
-
+    /* Program commands */
     PFNGLCREATEPROGRAMPROC CreateProgram;
     PFNGLLINKPROGRAMPROC   LinkProgram;
     PFNGLUSEPROGRAMPROC    UseProgram;
     PFNGLDELETEPROGRAMPROC DeleteProgram;
 
-    PFNGLATTACHSHADERPROC  AttachShader;
-
-    /* Shader log commands */
-    PFNGLGETPROGRAMIVPROC  GetProgramiv;
-    PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
-    PFNGLGETSHADERIVPROC   GetShaderiv;
-    PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
-
     /* Texture commands */
-    PFNGLACTIVETEXTUREPROC          ActiveTexture;
-    PFNGLBINDTEXTUREPROC            BindTexture;
-    PFNGLTEXPARAMETERIPROC          TexParameteri;
-    PFNGLTEXPARAMETERFPROC          TexParameterf;
-    PFNGLGETTEXLEVELPARAMETERIVPROC GetTexLevelParameteriv; /* OpenGL only */
-    PFNGLPIXELSTOREIPROC            PixelStorei;
-    PFNGLGENTEXTURESPROC            GenTextures;
-    PFNGLDELETETEXTURESPROC         DeleteTextures;
-    PFNGLTEXIMAGE2DPROC             TexImage2D;
-    PFNGLTEXSUBIMAGE2DPROC          TexSubImage2D;
+    PFNGLACTIVETEXTUREPROC ActiveTexture;
 
     /* Buffers commands */
     PFNGLGENBUFFERSPROC    GenBuffers;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 9ae57c3457..331f1879d4 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -679,6 +679,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
     }
 #endif
 
+#define GET_PROC_ADDR_CORE(name) vgl->vt.name = gl##name
 #define GET_PROC_ADDR_EXT(name, critical) do { \
     vgl->vt.name = vlc_gl_GetProcAddress(gl, "gl"#name); \
     if (vgl->vt.name == NULL && critical) { \
@@ -688,29 +689,39 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
     } \
 } while(0)
 #if defined(USE_OPENGL_ES2)
-#define GET_PROC_ADDR(name) vgl->vt.name = gl##name
-#define GET_PROC_ADDR_GL(name) vgl->vt.name = NULL /* GL only functions (not GLES) */
+#define GET_PROC_ADDR(name) GET_PROC_ADDR_CORE(name)
+#define GET_PROC_ADDR_CORE_GL(name) vgl->vt.name = NULL /* GL only functions (not GLES) */
 #else
 #define GET_PROC_ADDR(name) GET_PROC_ADDR_EXT(name, true)
-#define GET_PROC_ADDR_GL(name) GET_PROC_ADDR(name)
+#define GET_PROC_ADDR_CORE_GL(name) GET_PROC_ADDR_CORE(name)
 #endif
 #define GET_PROC_ADDR_OPTIONAL(name) GET_PROC_ADDR_EXT(name, false) /* GL 3 or more */
-    GET_PROC_ADDR(GetError);
-    GET_PROC_ADDR(GetString);
-    GET_PROC_ADDR(GetIntegerv);
+
+    GET_PROC_ADDR_CORE(GetError);
+    GET_PROC_ADDR_CORE(GetString);
+    GET_PROC_ADDR_CORE(GetIntegerv);
+    GET_PROC_ADDR_CORE(BindTexture);
+    GET_PROC_ADDR_CORE(TexParameteri);
+    GET_PROC_ADDR_CORE(TexParameterf);
+    GET_PROC_ADDR_CORE(PixelStorei);
+    GET_PROC_ADDR_CORE(GenTextures);
+    GET_PROC_ADDR_CORE(DeleteTextures);
+    GET_PROC_ADDR_CORE(TexImage2D);
+    GET_PROC_ADDR_CORE(TexSubImage2D);
+
+    GET_PROC_ADDR_CORE_GL(GetTexLevelParameteriv);
 
     GET_PROC_ADDR(CreateShader);
     GET_PROC_ADDR(ShaderSource);
     GET_PROC_ADDR(CompileShader);
     GET_PROC_ADDR(AttachShader);
+    GET_PROC_ADDR(DeleteShader);
 
     GET_PROC_ADDR(GetProgramiv);
     GET_PROC_ADDR(GetShaderiv);
     GET_PROC_ADDR(GetProgramInfoLog);
     GET_PROC_ADDR(GetShaderInfoLog);
 
-    GET_PROC_ADDR(DeleteShader);
-
     GET_PROC_ADDR(GetUniformLocation);
     GET_PROC_ADDR(GetAttribLocation);
     GET_PROC_ADDR(VertexAttribPointer);
@@ -727,15 +738,6 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
     GET_PROC_ADDR(DeleteProgram);
 
     GET_PROC_ADDR(ActiveTexture);
-    GET_PROC_ADDR(BindTexture);
-    GET_PROC_ADDR(TexParameteri);
-    GET_PROC_ADDR(TexParameterf);
-    GET_PROC_ADDR_GL(GetTexLevelParameteriv);
-    GET_PROC_ADDR(PixelStorei);
-    GET_PROC_ADDR(GenTextures);
-    GET_PROC_ADDR(DeleteTextures);
-    GET_PROC_ADDR(TexImage2D);
-    GET_PROC_ADDR(TexSubImage2D);
 
     GET_PROC_ADDR(GenBuffers);
     GET_PROC_ADDR(BindBuffer);



More information about the vlc-commits mailing list