diff options
author | David Tardon <dtardon@redhat.com> | 2014-05-20 17:19:13 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-05-20 19:24:17 +0200 |
commit | 4ffc7955361f38140fbacc41a0f473de5173c2dc (patch) | |
tree | 76bd8fbbc7469212f8c00f74c2380207a3044549 /slideshow | |
parent | fdo#60338: Introduce osl_createDirectoryWithFlags (diff) | |
download | core-4ffc7955361f38140fbacc41a0f473de5173c2dc.tar.gz core-4ffc7955361f38140fbacc41a0f473de5173c2dc.zip |
avoid duplication
Change-Id: I2de8da0ce3648657977825309d4dd9902c0f8900
Diffstat (limited to 'slideshow')
-rw-r--r-- | slideshow/source/engine/OGLTrans/generic/OGLTrans_Shaders.cxx | 87 |
1 files changed, 46 insertions, 41 deletions
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_Shaders.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_Shaders.cxx index 9e0445270594..191bca8893b7 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_Shaders.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_Shaders.cxx @@ -47,15 +47,42 @@ #else // UNX == X11 -namespace unx -{ #define GLX_GLXEXT_PROTOTYPES 1 #include <GL/glx.h> #include <GL/glxext.h> + +#endif + +namespace +{ + +typedef void (*GLFunction_t)(); + +#ifdef _WIN32 + +GLFunction_t lcl_glGetProcAddress(const char *const name) +{ + return wglGetProcAddress(name); +} + +#elif defined(MACOSX) + +GLFunction_t lcl_glGetProcAddress(const char *const name) +{ + return 0; +} + +#else // UNX == X11 + +GLFunction_t lcl_glGetProcAddress(const char *const name) +{ + return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)); } #endif +} + bool OGLShaders::cbInitialized = false; #ifdef GL_VERSION_2_0 @@ -83,46 +110,24 @@ bool OGLShaders::Initialize() { #ifdef GL_VERSION_2_0 if( !cbInitialized ) { -#ifdef _WIN32 - glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress( "glActiveTexture" ); - glCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress( "glCreateShader" ); - glShaderSource = (PFNGLSHADERSOURCEPROC) wglGetProcAddress( "glShaderSource" ); - glCompileShader = (PFNGLCOMPILESHADERPROC) wglGetProcAddress( "glCompileShader" ); - glGetShaderiv = (PFNGLGETSHADERIVPROC) wglGetProcAddress( "glGetShaderiv" ); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) wglGetProcAddress( "glGetShaderInfoLog" ); - glDeleteShader = (PFNGLDELETESHADERPROC) wglGetProcAddress( "glDeleteShader" ); - glCreateProgram = (PFNGLCREATEPROGRAMPROC) wglGetProcAddress( "glCreateProgram" ); - glAttachShader = (PFNGLATTACHSHADERPROC) wglGetProcAddress( "glAttachShader" ); - glLinkProgram = (PFNGLLINKPROGRAMPROC) wglGetProcAddress( "glLinkProgram" ); - glGetProgramiv = (PFNGLGETPROGRAMIVPROC) wglGetProcAddress( "glGetProgramiv" ); - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) wglGetProcAddress( "glGetProgramInfoLog" ); - glUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress( "glUseProgram" ); - glDeleteProgram = (PFNGLDELETEPROGRAMPROC) wglGetProcAddress( "glDeleteProgram" ); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) wglGetProcAddress( "glGetUniformLocation" ); - glUniform1i = (PFNGLUNIFORM1IPROC) wglGetProcAddress( "glUniform1i" ); - glUniform1f = (PFNGLUNIFORM1FPROC) wglGetProcAddress( "glUniform1f" ); + glActiveTexture = (PFNGLACTIVETEXTUREPROC) lcl_glGetProcAddress( "glActiveTexture" ); + glCreateShader = (PFNGLCREATESHADERPROC) lcl_glGetProcAddress( "glCreateShader" ); + glShaderSource = (PFNGLSHADERSOURCEPROC) lcl_glGetProcAddress( "glShaderSource" ); + glCompileShader = (PFNGLCOMPILESHADERPROC) lcl_glGetProcAddress( "glCompileShader" ); + glGetShaderiv = (PFNGLGETSHADERIVPROC) lcl_glGetProcAddress( "glGetShaderiv" ); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) lcl_glGetProcAddress( "glGetShaderInfoLog" ); + glDeleteShader = (PFNGLDELETESHADERPROC) lcl_glGetProcAddress( "glDeleteShader" ); + glCreateProgram = (PFNGLCREATEPROGRAMPROC) lcl_glGetProcAddress( "glCreateProgram" ); + glAttachShader = (PFNGLATTACHSHADERPROC) lcl_glGetProcAddress( "glAttachShader" ); + glLinkProgram = (PFNGLLINKPROGRAMPROC) lcl_glGetProcAddress( "glLinkProgram" ); + glGetProgramiv = (PFNGLGETPROGRAMIVPROC) lcl_glGetProcAddress( "glGetProgramiv" ); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) lcl_glGetProcAddress( "glGetProgramInfoLog" ); + glUseProgram = (PFNGLUSEPROGRAMPROC) lcl_glGetProcAddress( "glUseProgram" ); + glDeleteProgram = (PFNGLDELETEPROGRAMPROC) lcl_glGetProcAddress( "glDeleteProgram" ); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) lcl_glGetProcAddress( "glGetUniformLocation" ); + glUniform1i = (PFNGLUNIFORM1IPROC) lcl_glGetProcAddress( "glUniform1i" ); + glUniform1f = (PFNGLUNIFORM1FPROC) lcl_glGetProcAddress( "glUniform1f" ); cbInitialized = true; -#elif defined(MACOSX) -#else - glActiveTexture = (PFNGLACTIVETEXTUREPROC) unx::glXGetProcAddress( (unsigned char *) "glActiveTexture" ); - glCreateShader = (PFNGLCREATESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glCreateShader" ); - glShaderSource = (PFNGLSHADERSOURCEPROC) unx::glXGetProcAddress( (unsigned char *) "glShaderSource" ); - glCompileShader = (PFNGLCOMPILESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glCompileShader" ); - glGetShaderiv = (PFNGLGETSHADERIVPROC) unx::glXGetProcAddress( (unsigned char *) "glGetShaderiv" ); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) unx::glXGetProcAddress( (unsigned char *) "glGetShaderInfoLog" ); - glDeleteShader = (PFNGLDELETESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glDeleteShader" ); - glCreateProgram = (PFNGLCREATEPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glCreateProgram" ); - glAttachShader = (PFNGLATTACHSHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glAttachShader" ); - glLinkProgram = (PFNGLLINKPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glLinkProgram" ); - glGetProgramiv = (PFNGLGETPROGRAMIVPROC) unx::glXGetProcAddress( (unsigned char *) "glGetProgramiv" ); - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) unx::glXGetProcAddress( (unsigned char *) "glGetProgramInfoLog" ); - glUseProgram = (PFNGLUSEPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glUseProgram" ); - glDeleteProgram = (PFNGLDELETEPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glDeleteProgram" ); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) unx::glXGetProcAddress( (unsigned char *) "glGetUniformLocation" ); - glUniform1i = (PFNGLUNIFORM1IPROC) unx::glXGetProcAddress( (unsigned char *) "glUniform1i" ); - glUniform1f = (PFNGLUNIFORM1FPROC) unx::glXGetProcAddress( (unsigned char *) "glUniform1f" ); - cbInitialized = true; -#endif } return glCreateShader != NULL; |