diff options
author | Tor Lillqvist <tml@collabora.com> | 2014-04-08 14:21:41 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-04-08 14:45:49 +0300 |
commit | 486b47ae45727402317bed047c80a6ab7e134491 (patch) | |
tree | 8bcd78a2856c94ebd829a5bcadee651976809753 /include | |
parent | 76c9cd64e03d16f5df0da35dba5bf7e1a91e0e9f (diff) |
Make it compile for iOS and maybe Android, too
Don't include X11 headers where there is no X.
Include a copy of gluCheckExtension as there is no glu on either iOS nor Android.
Change-Id: Idf387a4eda5a8410d1511d6e0db78c0742af5a99
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/OpenGLContext.hxx | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx index b62448a2e241..220efb5b75e4 100644 --- a/include/vcl/OpenGLContext.hxx +++ b/include/vcl/OpenGLContext.hxx @@ -10,9 +10,13 @@ #ifndef VCL_OPENGL_CONTEXT_HXX #define VCL_OPENGL_CONTEXT_HXX +#include <string.h> + #include <GL/glew.h> #if defined( MACOSX ) +#elif defined( IOS ) +#elif defined( ANDROID ) #elif defined( UNX ) # include <prex.h> # include "GL/glxew.h" @@ -27,6 +31,8 @@ #include <GL/glext.h> #include <GL/wglext.h> #elif defined( MACOSX ) +#elif defined( IOS ) +#elif defined( ANDROID ) #elif defined( UNX ) #include <GL/glext.h> #define GLX_GLXEXT_PROTOTYPES 1 @@ -43,11 +49,50 @@ /// Holds the information of our new child window struct GLWindow { + // Copy of gluCheckExtension(), from the Apache-licensed + // https://code.google.com/p/glues/source/browse/trunk/glues/source/glues_registry.c + static GLboolean checkExtension(const GLubyte* extName, const GLubyte* extString) + { + GLboolean flag=GL_FALSE; + char* word; + char* lookHere; + char* deleteThis; + + if (extString==NULL) + { + return GL_FALSE; + } + + deleteThis=lookHere=(char*)malloc(strlen((const char*)extString)+1); + if (lookHere==NULL) + { + return GL_FALSE; + } + + /* strtok() will modify string, so copy it somewhere */ + strcpy(lookHere,(const char*)extString); + + while ((word=strtok(lookHere, " "))!=NULL) + { + if (strcmp(word,(const char*)extName)==0) + { + flag=GL_TRUE; + break; + } + lookHere=NULL; /* get next token */ + } + free((void*)deleteThis); + + return flag; + } + #if defined( _WIN32 ) HWND hWnd; HDC hDC; HGLRC hRC; #elif defined( MACOSX ) +#elif defined( IOS ) +#elif defined( ANDROID ) #elif defined( UNX ) Display* dpy; int screen; @@ -58,7 +103,7 @@ struct GLWindow XVisualInfo* vi; GLXContext ctx; - bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); } + bool HasGLXExtension( const char* name ) { return checkExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); } const char* GLXExtensions; #endif unsigned int bpp; @@ -67,12 +112,14 @@ struct GLWindow const GLubyte* GLExtensions; bool bMultiSampleSupported; - bool HasGLExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, GLExtensions ); } + bool HasGLExtension( const char* name ) { return checkExtension( (const GLubyte*) name, GLExtensions ); } GLWindow() : #if defined( _WIN32 ) #elif defined( MACOSX ) +#elif defined( IOS ) +#elif defined( ANDROID ) #elif defined( UNX ) dpy(NULL), screen(0), |