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.

(cherry picked from commit 768e925271)
This commit is contained in:
Rémi Verschelde 2016-06-07 19:59:33 +02:00
parent 64507f0085
commit 66ce012ca6
12 changed files with 23 additions and 29 deletions

View File

@ -80,8 +80,6 @@
#define __glew_h__ #define __glew_h__
#define __GLEW_H__ #define __GLEW_H__
#define GLEW_STATIC
#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H) #if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)
#error gl.h included before glew.h #error gl.h included before glew.h
#endif #endif

View File

@ -80,8 +80,6 @@
#define __glxew_h__ #define __glxew_h__
#define __GLXEW_H__ #define __GLXEW_H__
#define GLEW_STATIC
#ifdef __glxext_h_ #ifdef __glxext_h_
#error glxext.h included before glxew.h #error glxext.h included before glxew.h
#endif #endif
@ -99,7 +97,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xmd.h> #include <X11/Xmd.h>
#include "drivers/gl_context/glew.h" #include <GL/glew.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -56,8 +56,6 @@
#define __wglew_h__ #define __wglew_h__
#define __WGLEW_H__ #define __WGLEW_H__
#define GLEW_STATIC
#ifdef __wglext_h_ #ifdef __wglext_h_
#error wglext.h included before wglew.h #error wglext.h included before wglew.h
#endif #endif

View File

@ -1,5 +1,11 @@
Import('env') Import('env')
Export('env');
env.add_source_files(env.drivers_sources,"*.cpp") 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')

View File

@ -1,4 +1,3 @@
#ifdef GLEW_ENABLED
/* /*
** The OpenGL Extension Wrangler Library ** The OpenGL Extension Wrangler Library
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org> ** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
@ -30,11 +29,11 @@
** THE POSSIBILITY OF SUCH DAMAGE. ** THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "drivers/gl_context/glew.h" #include <GL/glew.h>
#if defined(_WIN32) #if defined(_WIN32)
# include "drivers/gl_context/wglew.h" # include <GL/wglew.h>
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
# include "drivers/gl_context/glxew.h" # include <GL/glxew.h>
#endif #endif
/* /*
@ -15156,5 +15155,3 @@ GLboolean glxewIsSupported (const char* name)
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
#endif

View File

@ -23,7 +23,8 @@ def get_opts():
def get_flags(): def get_flags():
return [ return [
('builtin_zlib', 'no') ('builtin_zlib', 'no'),
#('glew', 'yes'), # TODO: investigate the GLEW situation on Haiku
] ]
def configure(env): def configure(env):
@ -52,7 +53,6 @@ def configure(env):
#env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) #env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
env.Append(CPPFLAGS = ['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np 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 = ['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED'])
env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL'])

View File

@ -28,10 +28,10 @@ def get_opts():
def get_flags(): def get_flags():
return [ return [
('opengl', 'no'),
('legacygl', 'yes'), ('legacygl', 'yes'),
('builtin_zlib', 'no'), ('builtin_zlib', 'no'),
('freetype','builtin'), #use builtin freetype ('freetype','builtin'), #use builtin freetype
('glew', 'yes'),
] ]
@ -94,11 +94,8 @@ def configure(env):
# env.Append(LIBPATH=['#platform/osx/lib']) # 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=["-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(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(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']) #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'])

View File

@ -27,6 +27,5 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include <alloca.h> #include <alloca.h>
#define GLES2_INCLUDE_H "gl_context/glew.h" #define GLES2_INCLUDE_H "gl_context/GL/glew.h"
#define GLES1_INCLUDE_H "gl_context/glew.h"
#define PTHREAD_RENAME_SELF #define PTHREAD_RENAME_SELF

View File

@ -169,6 +169,7 @@ def get_flags():
return [ return [
('freetype','builtin'), #use builtin freetype ('freetype','builtin'), #use builtin freetype
('glew','yes'),
('openssl','builtin'), #use builtin openssl ('openssl','builtin'), #use builtin openssl
] ]
@ -242,7 +243,6 @@ def configure(env):
env.Append(CCFLAGS=['/DGLES2_ENABLED']) 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'] 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]) env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS])
@ -368,7 +368,7 @@ def configure(env):
env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows']) env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows'])
env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) 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']) env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','kernel32', 'oleaut32', 'dinput8', 'dxguid'])
# if (env["bits"]=="32"): # if (env["bits"]=="32"):

View File

@ -30,6 +30,6 @@
//#else //#else
//#include <alloca.h> //#include <alloca.h>
//#endif //#endif
#define GLES2_INCLUDE_H "gl_context/glew.h" #define GLES2_INCLUDE_H "gl_context/GL/glew.h"

View File

@ -65,6 +65,7 @@ def get_flags():
return [ return [
('builtin_zlib', 'no'), ('builtin_zlib', 'no'),
('glew', 'yes'),
("openssl", "yes"), ("openssl", "yes"),
#("theora","no"), #("theora","no"),
] ]
@ -147,7 +148,7 @@ def configure(env):
env.Append(CPPPATH=['#tools/freetype/freetype/include']) env.Append(CPPPATH=['#tools/freetype/freetype/include'])
env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) env.Append(CPPFLAGS=['-DOPENGL_ENABLED'])
if os.system("pkg-config --exists alsa")==0: if os.system("pkg-config --exists alsa")==0:
print("Enabling ALSA") print("Enabling ALSA")

View File

@ -34,6 +34,6 @@
#define PTHREAD_BSD_SET_NAME #define PTHREAD_BSD_SET_NAME
#endif #endif
#define GLES2_INCLUDE_H "gl_context/glew.h" #define GLES2_INCLUDE_H "gl_context/GL/glew.h"