Kaydet (Commit) 486b47ae authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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
üst 76c9cd64
...@@ -10,9 +10,13 @@ ...@@ -10,9 +10,13 @@
#ifndef VCL_OPENGL_CONTEXT_HXX #ifndef VCL_OPENGL_CONTEXT_HXX
#define VCL_OPENGL_CONTEXT_HXX #define VCL_OPENGL_CONTEXT_HXX
#include <string.h>
#include <GL/glew.h> #include <GL/glew.h>
#if defined( MACOSX ) #if defined( MACOSX )
#elif defined( IOS )
#elif defined( ANDROID )
#elif defined( UNX ) #elif defined( UNX )
# include <prex.h> # include <prex.h>
# include "GL/glxew.h" # include "GL/glxew.h"
...@@ -27,6 +31,8 @@ ...@@ -27,6 +31,8 @@
#include <GL/glext.h> #include <GL/glext.h>
#include <GL/wglext.h> #include <GL/wglext.h>
#elif defined( MACOSX ) #elif defined( MACOSX )
#elif defined( IOS )
#elif defined( ANDROID )
#elif defined( UNX ) #elif defined( UNX )
#include <GL/glext.h> #include <GL/glext.h>
#define GLX_GLXEXT_PROTOTYPES 1 #define GLX_GLXEXT_PROTOTYPES 1
...@@ -43,11 +49,50 @@ ...@@ -43,11 +49,50 @@
/// Holds the information of our new child window /// Holds the information of our new child window
struct GLWindow 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 ) #if defined( _WIN32 )
HWND hWnd; HWND hWnd;
HDC hDC; HDC hDC;
HGLRC hRC; HGLRC hRC;
#elif defined( MACOSX ) #elif defined( MACOSX )
#elif defined( IOS )
#elif defined( ANDROID )
#elif defined( UNX ) #elif defined( UNX )
Display* dpy; Display* dpy;
int screen; int screen;
...@@ -58,7 +103,7 @@ struct GLWindow ...@@ -58,7 +103,7 @@ struct GLWindow
XVisualInfo* vi; XVisualInfo* vi;
GLXContext ctx; 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; const char* GLXExtensions;
#endif #endif
unsigned int bpp; unsigned int bpp;
...@@ -67,12 +112,14 @@ struct GLWindow ...@@ -67,12 +112,14 @@ struct GLWindow
const GLubyte* GLExtensions; const GLubyte* GLExtensions;
bool bMultiSampleSupported; 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() GLWindow()
: :
#if defined( _WIN32 ) #if defined( _WIN32 )
#elif defined( MACOSX ) #elif defined( MACOSX )
#elif defined( IOS )
#elif defined( ANDROID )
#elif defined( UNX ) #elif defined( UNX )
dpy(NULL), dpy(NULL),
screen(0), screen(0),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment