From e81e12ded03c6561cb2a7ca312aba25785da3869 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Fri, 4 May 2012 14:15:10 -0500 Subject: [PATCH] Initial #ifdef __ANDROID__ support for the GLEW build. --- auto/src/glew_head.c | 29 ++++++++++++++++++----------- auto/src/glew_init_tail.c | 4 ++-- auto/src/glew_utils.c | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/auto/src/glew_head.c b/auto/src/glew_head.c index b07db75..d12e8c2 100644 --- a/auto/src/glew_head.c +++ b/auto/src/glew_head.c @@ -1,7 +1,8 @@ #include + #if defined(_WIN32) # include -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) +#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) # include #endif @@ -72,7 +73,11 @@ void* NSGLGetProcAddress (const GLubyte *name) void* addr; if (NULL == image) { +#ifdef GLEW_REGAL + image = dlopen("libRegal.dylib", RTLD_LAZY); +#else image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); +#endif } if( !image ) return NULL; addr = dlsym(image, (const char*)name); @@ -94,7 +99,11 @@ void* NSGLGetProcAddress (const GLubyte *name) char* symbolName; if (NULL == image) { +#ifdef GLEW_REGAL + image = NSAddImage("libRegal.dylib", NSADDIMAGE_OPTION_RETURN_ON_ERROR); +#else image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); +#endif } /* prepend a '_' for the Unix C symbol mangling convention */ symbolName = malloc(strlen((const char*)name) + 2); @@ -120,16 +129,14 @@ void* NSGLGetProcAddress (const GLubyte *name) */ #if defined(_WIN32) # define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name) -#else -# if defined(__APPLE__) -# define glewGetProcAddress(name) NSGLGetProcAddress(name) -# else -# if defined(__sgi) || defined(__sun) -# define glewGetProcAddress(name) dlGetProcAddress(name) -# else /* __linux */ -# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name) -# endif -# endif +#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) +# define glewGetProcAddress(name) NSGLGetProcAddress(name) +#elif defined(__sgi) || defined(__sun) +# define glewGetProcAddress(name) dlGetProcAddress(name) +#elif defined(__ANDROID__) +# define glewGetProcAddress(name) NULL /* TODO */ +#else /* __linux */ +# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name) #endif /* diff --git a/auto/src/glew_init_tail.c b/auto/src/glew_init_tail.c index a4dbb81..03afcba 100644 --- a/auto/src/glew_init_tail.c +++ b/auto/src/glew_init_tail.c @@ -36,7 +36,7 @@ GLboolean glewExperimental = GL_FALSE; #if defined(_WIN32) extern GLenum wglewContextInit (void); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ +#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) extern GLenum glxewContextInit (void); #endif /* _WIN32 */ @@ -47,7 +47,7 @@ GLenum glewInit (void) if ( r != 0 ) return r; #if defined(_WIN32) return wglewContextInit(); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ +#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) /* _UNIX */ return glxewContextInit(); #else return r; diff --git a/auto/src/glew_utils.c b/auto/src/glew_utils.c index 85fb57f..e31f048 100644 --- a/auto/src/glew_utils.c +++ b/auto/src/glew_utils.c @@ -32,7 +32,7 @@ #include #if defined(_WIN32) # include -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) +#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) # include #endif