From 768e9252714b57421b5c893a8258469a14630a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 7 Jun 2016 19:59:33 +0200 Subject: [PATCH] GLEW: Define static + enabled and includes via SCons This allows us not to have to hack our definitions in the upstream files, making it easier to upgrade to newer versions in the future. For the include paths to work, the headers are moved to a GL subfolder to match their upstream location. --- drivers/gl_context/{ => GL}/glew.h | 2 -- drivers/gl_context/{ => GL}/glxew.h | 4 +--- drivers/gl_context/{ => GL}/wglew.h | 2 -- drivers/gl_context/SCsub | 10 ++++++++-- drivers/gl_context/glew.c | 9 +++------ platform/haiku/detect.py | 4 ++-- platform/osx/detect.py | 7 ++----- platform/osx/platform_config.h | 3 +-- platform/windows/detect.py | 4 ++-- platform/windows/platform_config.h | 2 +- platform/x11/detect.py | 3 ++- platform/x11/platform_config.h | 2 +- 12 files changed, 23 insertions(+), 29 deletions(-) rename drivers/gl_context/{ => GL}/glew.h (99%) rename drivers/gl_context/{ => GL}/glxew.h (99%) rename drivers/gl_context/{ => GL}/wglew.h (99%) diff --git a/drivers/gl_context/glew.h b/drivers/gl_context/GL/glew.h similarity index 99% rename from drivers/gl_context/glew.h rename to drivers/gl_context/GL/glew.h index 39c8162dead..3de3e86a4fd 100644 --- a/drivers/gl_context/glew.h +++ b/drivers/gl_context/GL/glew.h @@ -80,8 +80,6 @@ #define __glew_h__ #define __GLEW_H__ -#define GLEW_STATIC - #if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H) #error gl.h included before glew.h #endif diff --git a/drivers/gl_context/glxew.h b/drivers/gl_context/GL/glxew.h similarity index 99% rename from drivers/gl_context/glxew.h rename to drivers/gl_context/GL/glxew.h index 985c946d83b..ab4d03da41d 100644 --- a/drivers/gl_context/glxew.h +++ b/drivers/gl_context/GL/glxew.h @@ -80,8 +80,6 @@ #define __glxew_h__ #define __GLXEW_H__ -#define GLEW_STATIC - #ifdef __glxext_h_ #error glxext.h included before glxew.h #endif @@ -99,7 +97,7 @@ #include #include #include -#include "drivers/gl_context/glew.h" +#include #ifdef __cplusplus extern "C" { diff --git a/drivers/gl_context/wglew.h b/drivers/gl_context/GL/wglew.h similarity index 99% rename from drivers/gl_context/wglew.h rename to drivers/gl_context/GL/wglew.h index a6722748be6..ae06b0cba9e 100644 --- a/drivers/gl_context/wglew.h +++ b/drivers/gl_context/GL/wglew.h @@ -56,8 +56,6 @@ #define __wglew_h__ #define __WGLEW_H__ -#define GLEW_STATIC - #ifdef __wglext_h_ #error wglext.h included before wglew.h #endif diff --git a/drivers/gl_context/SCsub b/drivers/gl_context/SCsub index 7cf8629fe18..dac27c01250 100644 --- a/drivers/gl_context/SCsub +++ b/drivers/gl_context/SCsub @@ -1,5 +1,11 @@ Import('env') -Export('env'); env.add_source_files(env.drivers_sources,"*.cpp") -env.add_source_files(env.drivers_sources,"*.c") + +if (env.get('glew') == 'yes'): + env.add_source_files(env.drivers_sources,"glew.c") + env.Append(CPPFLAGS = ['-DGLEW_ENABLED']) + env.Append(CPPFLAGS = ['-DGLEW_STATIC']) + env.Append(CPPPATH = ['.']) + +Export('env') diff --git a/drivers/gl_context/glew.c b/drivers/gl_context/glew.c index fc0aa28a720..df824f3c711 100644 --- a/drivers/gl_context/glew.c +++ b/drivers/gl_context/glew.c @@ -1,4 +1,3 @@ -#ifdef GLEW_ENABLED /* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2002-2008, Milan Ikits @@ -30,11 +29,11 @@ ** THE POSSIBILITY OF SUCH DAMAGE. */ -#include "drivers/gl_context/glew.h" +#include #if defined(_WIN32) -# include "drivers/gl_context/wglew.h" +# include #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -# include "drivers/gl_context/glxew.h" +# include #endif /* @@ -15156,5 +15155,3 @@ GLboolean glxewIsSupported (const char* name) } #endif /* _WIN32 */ - -#endif diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 2d132641f94..6d1a96a8daf 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -23,7 +23,8 @@ def get_opts(): def get_flags(): return [ - ('builtin_zlib', 'no') + ('builtin_zlib', 'no'), + #('glew', 'yes'), # TODO: investigate the GLEW situation on Haiku ] def configure(env): @@ -52,7 +53,6 @@ def configure(env): #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) env.Append(CPPFLAGS = ['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np - #env.Append(CPPFLAGS = ['-DGLEW_ENABLED']) # TODO: investigate the GLEW situation on Haiku env.Append(CPPFLAGS = ['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) diff --git a/platform/osx/detect.py b/platform/osx/detect.py index d668509b90a..d1aa54b71db 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -28,10 +28,10 @@ def get_opts(): def get_flags(): return [ - ('opengl', 'no'), ('legacygl', 'yes'), ('builtin_zlib', 'no'), ('freetype','builtin'), #use builtin freetype + ('glew', 'yes'), ] @@ -94,11 +94,8 @@ def configure(env): # env.Append(LIBPATH=['#platform/osx/lib']) - #if env['opengl'] == 'yes': - # env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) - env.Append(CPPFLAGS=["-DAPPLE_STYLE_KEYS"]) - env.Append(CPPFLAGS=['-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLEW_ENABLED', '-DOSX_ENABLED']) + env.Append(CPPFLAGS=['-DUNIX_ENABLED','-DGLES2_ENABLED','-DOSX_ENABLED']) env.Append(LIBS=['pthread']) #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4']) #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk']) diff --git a/platform/osx/platform_config.h b/platform/osx/platform_config.h index 085f13df73f..86505206aea 100644 --- a/platform/osx/platform_config.h +++ b/platform/osx/platform_config.h @@ -27,6 +27,5 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include -#define GLES2_INCLUDE_H "gl_context/glew.h" -#define GLES1_INCLUDE_H "gl_context/glew.h" +#define GLES2_INCLUDE_H "gl_context/GL/glew.h" #define PTHREAD_RENAME_SELF diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 97d2461e580..a6a949a11a1 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -169,6 +169,7 @@ def get_flags(): return [ ('freetype','builtin'), #use builtin freetype + ('glew','yes'), ('openssl','builtin'), #use builtin openssl ] @@ -242,7 +243,6 @@ def configure(env): env.Append(CCFLAGS=['/DGLES2_ENABLED']) - env.Append(CCFLAGS=['/DGLEW_ENABLED']) LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid'] env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS]) @@ -369,7 +369,7 @@ def configure(env): env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows']) env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLEW_ENABLED']) + env.Append(CCFLAGS=['-DGLES2_ENABLED']) env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','kernel32', 'oleaut32', 'dinput8', 'dxguid']) # if (env["bits"]=="32"): diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h index 55f6b5547e9..9e207508161 100644 --- a/platform/windows/platform_config.h +++ b/platform/windows/platform_config.h @@ -30,6 +30,6 @@ //#else //#include //#endif -#define GLES2_INCLUDE_H "gl_context/glew.h" +#define GLES2_INCLUDE_H "gl_context/GL/glew.h" diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 5a43bf9323e..2561e09b9ad 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -65,6 +65,7 @@ def get_flags(): return [ ('builtin_zlib', 'no'), + ('glew', 'yes'), ("openssl", "yes"), #("theora","no"), ] @@ -147,7 +148,7 @@ def configure(env): env.Append(CPPPATH=['#drivers/freetype/freetype/include']) - env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) + env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) if os.system("pkg-config --exists alsa")==0: print("Enabling ALSA") diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h index aac50c27c2e..3b47b2c92d7 100644 --- a/platform/x11/platform_config.h +++ b/platform/x11/platform_config.h @@ -34,6 +34,6 @@ #define PTHREAD_BSD_SET_NAME #endif -#define GLES2_INCLUDE_H "gl_context/glew.h" +#define GLES2_INCLUDE_H "gl_context/GL/glew.h"