From e21be8b86ab6bb46c2c3a643f7ad1ce05fb146e8 Mon Sep 17 00:00:00 2001 From: ikits Date: Sun, 1 Feb 2004 18:13:05 +0000 Subject: [PATCH] added glew mx git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@202 783a27ee-832a-0410-bc00-9f386506c6dd --- auto/Makefile | 35 ++++++++++++++------------ auto/bin/make.pl | 10 +++++++- auto/bin/make_header.pl | 7 +++--- auto/bin/make_info.pl | 2 +- auto/bin/make_init.pl | 21 +++++----------- auto/bin/make_list.pl | 18 ++++++-------- auto/bin/make_struct.pl | 51 ++++++++++++++++++++++++++++++++++++++ auto/core/GL_ARB_imaging | 2 -- auto/src/glew_gl.c | 53 ++++++++++++++++++++++++---------------- auto/src/glew_glx.c | 24 +++++++++++------- auto/src/glew_post.c | 6 ++--- auto/src/glew_post.h | 13 ++++++++++ auto/src/glew_pre.c | 15 +++++++----- auto/src/glew_pre.h | 5 ++-- auto/src/glew_wgl.c | 29 +++++++++++++--------- auto/src/wglew_post.h | 12 +++++++++ 16 files changed, 201 insertions(+), 102 deletions(-) create mode 100755 auto/bin/make_struct.pl diff --git a/auto/Makefile b/auto/Makefile index 5d589f4..87bcdbb 100644 --- a/auto/Makefile +++ b/auto/Makefile @@ -13,7 +13,7 @@ GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO) SHELL = bash REGISTRY = registry -REGISTRY_URL = http://oss.sgi.com/projects/ogl-sample/registry/ +REGISTRY_URL = http://oss.sgi.com/projects/ogl-sample/registry/ BIN = bin SRC = src CORE = core @@ -58,16 +58,20 @@ endif $(I.DEST)/glew.h: $(EXT)/.dummy test -d $(I.DEST) || mkdir -p $(I.DEST) cp -f $(SRC)/glew_pre.h $@ - $(BIN)/make_header.pl GLAPIENTRY $(CORE)/GL_VERSION* >> $@ - mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \ - grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \ - grep -v 'glBlendEquation' > $@; rm tmp; - $(BIN)/make_header.pl GLAPIENTRY $(EXT)/GL_* >> $@ + $(BIN)/make_header_def.pl GLAPIENTRY GL $(CORE)/GL_VERSION* >> $@ +# mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \ +# grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \ +# grep -v 'glBlendEquation' > $@; rm tmp; + $(BIN)/make_header_def.pl GLAPIENTRY GL $(EXT)/GL_* >> $@ + $(BIN)/make_struct.pl GL $(CORE)/GL_VERSION* $(EXT)/GL_* >> $@ + perl -e 's/ GLboolean __GLEW_VERSION_1_2;/\n GLboolean __GLEW_VERSION_1_1;\n GLboolean __GLEW_VERSION_1_2;/' -pi.bak $@ + rm -f $@.bak cat $(SRC)/glew_post.h >> $@ $(I.DEST)/wglew.h: $(EXT)/.dummy cp -f $(SRC)/wglew_pre.h $@ - $(BIN)/make_header.pl WINAPI $(EXT)/WGL_* >> $@ + $(BIN)/make_header_def.pl WINAPI WGL $(EXT)/WGL_* >> $@ + $(BIN)/make_struct.pl WGL $(EXT)/WGL_* >> $@ cat $(SRC)/wglew_post.h >> $@ $(I.DEST)/glxew.h: $(EXT)/.dummy @@ -79,17 +83,16 @@ $(I.DEST)/glxew.h: $(EXT)/.dummy $(S.DEST)/glew.c: $(EXT)/.dummy cp -f $(SRC)/glew_pre.c $@ - $(BIN)/make_init.pl $(CORE)/GL_VERSION* >> $@ - mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \ - grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \ - grep -v 'glBlendEquation' > $@; rm tmp; - $(BIN)/make_init.pl $(EXT)/GL_* >> $@ + $(BIN)/make_init.pl GL $(CORE)/GL_VERSION* >> $@ +# mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \ +# grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \ +# grep -v 'glBlendEquation' > $@; rm tmp; + $(BIN)/make_init.pl GL $(EXT)/GL_* >> $@ echo -e "#ifdef _WIN32\n" >> $@ - $(BIN)/make_init.pl $(EXT)/WGL_* >> $@ + $(BIN)/make_init.pl WGL $(EXT)/WGL_* >> $@ echo -e "#else /* _UNIX */\n\n" >> $@ - cat $(SRC)/glew_init_glx.c >> $@ - $(BIN)/make_init.pl $(CORE)/GLX_VERSION* >> $@ - $(BIN)/make_init.pl $(EXT)/GLX_* >> $@ + $(BIN)/make_init.pl GLX $(CORE)/GLX_VERSION* >> $@ + $(BIN)/make_init.pl GLX $(EXT)/GLX_* >> $@ echo -e "#endif /* _WIN32 */\n" >> $@ cat $(SRC)/glew_gl.c >> $@ diff --git a/auto/bin/make.pl b/auto/bin/make.pl index 33c3b5d..0dd1727 100755 --- a/auto/bin/make.pl +++ b/auto/bin/make.pl @@ -19,7 +19,15 @@ my %regex = ( sub prefixname($) { my $name = $_[0]; - $name =~ s/^(.*)gl/$1glew/; + $name =~ s/^(.*)gl/__$1glew/; + return $name; +} + +# prefix function name with glew +sub prefix_varname($) +{ + my $name = $_[0]; + $name =~ s/^(.*)GLEW/__$1GLEW/; return $name; } diff --git a/auto/bin/make_header.pl b/auto/bin/make_header.pl index fb5cce7..a56f468 100755 --- a/auto/bin/make_header.pl +++ b/auto/bin/make_header.pl @@ -36,7 +36,7 @@ sub make_pfn_type($%) # function name alias sub make_pfn_alias($%) { - return join(" ", "#define", $_[0], prefixname($_[0])) + return join(" ", "#define", $_[0], "GLEW_GET_CONTEXT(", $_[0], ")") } # function pointer declaration @@ -73,6 +73,7 @@ foreach my $ext (sort @extlist) my $extvar = $extname; $extvar =~ s/GL(X*)_/GL$1EW_/; - print "\nGLEWAPI GLboolean $extvar;\n\n"; - print "#endif /* $extname */\n\n"; + print "\nGLEWAPI GLboolean _$extvar;\n"; + print "\n#define $extvar GLEW_GET_CONTEXT($extvar);\n"; + print "\n#endif /* $extname */\n\n"; } diff --git a/auto/bin/make_info.pl b/auto/bin/make_info.pl index 9916507..e884dad 100755 --- a/auto/bin/make_info.pl +++ b/auto/bin/make_info.pl @@ -17,7 +17,7 @@ do 'bin/make.pl'; # function pointer definition sub make_pfn_info($%) { - my $name = prefixname($_[0]); + my $name = $_[0]; return " glewInfoFunc((const GLubyte*)\"$_[0]\", $name == NULL);"; } diff --git a/auto/bin/make_init.pl b/auto/bin/make_init.pl index 84e9c0a..4872c1a 100755 --- a/auto/bin/make_init.pl +++ b/auto/bin/make_init.pl @@ -14,17 +14,11 @@ do 'bin/make.pl'; #--------------------------------------------------------------------------------------- -# function pointer definition -sub make_pfn_def($%) -{ - return "PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . " = NULL;"; -} - # function pointer definition sub make_pfn_def_init($%) { my $name = prefixname($_[0]); - return " r = ((" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; + return " r = ((ctx->" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; } #--------------------------------------------------------------------------------------- @@ -32,6 +26,8 @@ sub make_pfn_def_init($%) my @extlist = (); my %extensions = (); +our $type = shift; + if (@ARGV) { @extlist = @ARGV; @@ -45,21 +41,16 @@ foreach my $ext (sort @extlist) my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext); make_separator($extname); - print "#ifdef $extname\n"; - if (keys %$functions) - { - output_decls($functions, \&make_pfn_def); - print "\n"; - } + print "#ifdef $extname\n\n"; my $extvar = $extname; my $extvardef = $extname; $extvar =~ s/GL(X*)_/GL$1EW_/; if (keys %$functions) { - print "static GLboolean _glewInit_$extname (void)\n{\n GLboolean r = GL_FALSE;\n"; + print "static GLboolean _glewInit_$extname (" . $type . "EWContext* ctx)\n{\n GLboolean r = GL_FALSE;\n"; output_decls($functions, \&make_pfn_def_init); print "\n return r;\n}\n"; } - print "\nGLboolean $extvar = GL_FALSE;\n\n"; + #print "\nGLboolean " . prefix_varname($extvar) . " = GL_FALSE;\n\n"; print "#endif /* $extname */\n\n"; } diff --git a/auto/bin/make_list.pl b/auto/bin/make_list.pl index 7f88dfc..aa818d3 100755 --- a/auto/bin/make_list.pl +++ b/auto/bin/make_list.pl @@ -14,17 +14,11 @@ do 'bin/make.pl'; #--------------------------------------------------------------------------------------- -# function pointer definition -sub make_pfn_def($%) -{ - return "PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . " = NULL;"; -} - # function pointer definition sub make_init_call($%) { my $name = prefixname($_[0]); - return " r = r || (" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;"; + return " r = r || (ctx->" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;"; } #--------------------------------------------------------------------------------------- @@ -49,18 +43,20 @@ foreach my $ext (sort @extlist) my $extpre = $extname; $extpre =~ s/^(W?)GL(X?).*$/\l$1gl\l$2ew/; - + + my $pextvar = prefix_varname($extvar); + print "#ifdef $extname\n"; - print " $extvar = " . $extpre . "GetExtension((const GLubyte*)\"$extname\");\n"; + print " ctx->" . $pextvar . "= " . $extpre . "GetExtension((const GLubyte*)\"$extname\");\n"; if (keys %$functions) { if ($extname =~ /WGL_.*/) { - print " if (glewExperimental || $extvar || crippled) $extvar = !_glewInit_$extname();\n"; + print " if (glewExperimental || ctx->" . $pextvar . "|| crippled) ctx->" . $pextvar . "= !_glewInit_$extname(ctx);\n"; } else { - print " if (glewExperimental || $extvar) $extvar = !_glewInit_$extname();\n"; + print " if (glewExperimental || ctx->" . $pextvar . ") ctx->" . $pextvar . " = !_glewInit_$extname(ctx);\n"; } } print "#endif /* $extname */\n"; diff --git a/auto/bin/make_struct.pl b/auto/bin/make_struct.pl new file mode 100755 index 0000000..ac2b1eb --- /dev/null +++ b/auto/bin/make_struct.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl +# +# Copyright (C) 2003 Marcelo E. Magallon +# Copyright (C) 2003 Milan Ikits +# +# This program is distributed under the terms and conditions of the GNU +# General Public License Version 2 as published by the Free Software +# Foundation or, at your option, any later version. + +use strict; +use warnings; + +do 'bin/make.pl'; + +# function pointer declaration +sub make_pfn_decl($%) +{ + return " PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . ";"; +} + +my @extlist = (); +my %extensions = (); + +our $type = shift; + +if (@ARGV) +{ + @extlist = @ARGV; +} else { + local $/; + @extlist = split "\n", (<>); +} + +print "/* ------------------------------------------------------------------------- */\n\n"; +print "struct " . $type . "EWContextStruct\n{"; + +foreach my $ext (sort @extlist) +{ + my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext); + output_decls($functions, \&make_pfn_decl); +} + +foreach my $ext (sort @extlist) +{ + my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext); + my $extvar = $extname; + $extvar =~ s/GL(X*)_/GL$1EW_/; + print " GLboolean " . prefix_varname($extvar) . ";\n"; +} + +print "\n}; /* " . $type . "EWContextStruct */\n\n"; diff --git a/auto/core/GL_ARB_imaging b/auto/core/GL_ARB_imaging index 20888a3..66dd527 100644 --- a/auto/core/GL_ARB_imaging +++ b/auto/core/GL_ARB_imaging @@ -76,8 +76,6 @@ GL_ARB_imaging GL_WRAP_BORDER 0x8152 GL_REPLICATE_BORDER 0x8153 GL_CONVOLUTION_BORDER_COLOR 0x8154 - void glBlendEquation (GLenum mode) - void glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) void glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table) void glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data) void glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params) diff --git a/auto/src/glew_gl.c b/auto/src/glew_gl.c index a4a29ca..c32c579 100644 --- a/auto/src/glew_gl.c +++ b/auto/src/glew_gl.c @@ -5,21 +5,21 @@ * These functions implement the functionality required in this file. */ -static GLuint _glewStrLen (const GLubyte *s) +static GLuint _glewStrLen (const GLubyte* s) { GLuint i=0; while (s+i != NULL && s[i] != '\0') i++; return i; } -static GLuint _glewStrCLen (const GLubyte *s, GLubyte c) +static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) { GLuint i=0; while (s+i != NULL && s[i] != '\0' && s[i] != c) i++; return i; } -static GLboolean _glewStrSame (const GLubyte *a, const GLubyte *b, GLuint n) +static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) { GLuint i=0; while (i < n && a+i != NULL && b+i != NULL && a[i] == b[i]) i++; @@ -32,9 +32,10 @@ static GLboolean _glewStrSame (const GLubyte *a, const GLubyte *b, GLuint n) * other extension names. Could use strtok() but the constant * string returned by glGetString might be in read-only memory. */ -GLboolean glewGetExtension (const GLubyte *name) +GLboolean glewGetExtension (const GLubyte* name) { - GLubyte *p, *end; + GLubyte* p; + GLubyte* end; GLuint len = _glewStrLen(name); p = (GLubyte*)glGetString(GL_EXTENSIONS); if (0 == p) return GL_FALSE; @@ -50,7 +51,7 @@ GLboolean glewGetExtension (const GLubyte *name) /* ------------------------------------------------------------------------- */ -static GLuint _glewInit () +GLenum glewContextInit (GLEWContext* ctx) { const GLubyte* s; GLuint i; @@ -66,33 +67,43 @@ static GLuint _glewInit () { if (s[3] >= '5') { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_TRUE; - GLEW_VERSION_1_4 = GL_TRUE; - GLEW_VERSION_1_5 = GL_TRUE; + ctx->__GLEW_VERSION_1_1 = GL_TRUE; + ctx->__GLEW_VERSION_1_2 = GL_TRUE; + ctx->__GLEW_VERSION_1_3 = GL_TRUE; + ctx->__GLEW_VERSION_1_4 = GL_TRUE; + ctx->__GLEW_VERSION_1_5 = GL_TRUE; } if (s[2] == '4') { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_TRUE; - GLEW_VERSION_1_4 = GL_TRUE; + ctx->__GLEW_VERSION_1_1 = GL_TRUE; + ctx->__GLEW_VERSION_1_2 = GL_TRUE; + ctx->__GLEW_VERSION_1_3 = GL_TRUE; + ctx->__GLEW_VERSION_1_4 = GL_TRUE; + ctx->__GLEW_VERSION_1_5 = GL_FALSE; } if (s[2] == '3') { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; - GLEW_VERSION_1_3 = GL_TRUE; + ctx->__GLEW_VERSION_1_1 = GL_TRUE; + ctx->__GLEW_VERSION_1_2 = GL_TRUE; + ctx->__GLEW_VERSION_1_3 = GL_TRUE; + ctx->__GLEW_VERSION_1_4 = GL_FALSE; + ctx->__GLEW_VERSION_1_5 = GL_FALSE; } if (s[2] == '2') { - GLEW_VERSION_1_1 = GL_TRUE; - GLEW_VERSION_1_2 = GL_TRUE; + ctx->__GLEW_VERSION_1_1 = GL_TRUE; + ctx->__GLEW_VERSION_1_2 = GL_TRUE; + ctx->__GLEW_VERSION_1_3 = GL_FALSE; + ctx->__GLEW_VERSION_1_4 = GL_FALSE; + ctx->__GLEW_VERSION_1_5 = GL_FALSE; } if (s[2] < '2') { - GLEW_VERSION_1_1 = GL_TRUE; + ctx->__GLEW_VERSION_1_1 = GL_TRUE; + ctx->__GLEW_VERSION_1_2 = GL_FALSE; + ctx->__GLEW_VERSION_1_3 = GL_FALSE; + ctx->__GLEW_VERSION_1_4 = GL_FALSE; + ctx->__GLEW_VERSION_1_5 = GL_FALSE; } } /* initialize extensions */ diff --git a/auto/src/glew_glx.c b/auto/src/glew_glx.c index aba4b0d..db4ca5c 100644 --- a/auto/src/glew_glx.c +++ b/auto/src/glew_glx.c @@ -3,9 +3,10 @@ #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ -GLboolean glxewGetExtension (const GLubyte *name) +GLboolean glxewGetExtension (const GLubyte* name) { - GLubyte *p, *end; + GLubyte* p; + GLubyte* end; GLuint len = _glewStrLen(name); if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); @@ -20,23 +21,28 @@ GLboolean glxewGetExtension (const GLubyte *name) return GL_FALSE; } -static GLuint _glxewInit () +GLenum glxewContextInit (GLXEWContext* ctx) { int major, minor; /* initialize core GLX 1.2 */ - if (_glewInit_GLX_VERSION_1_2()) return GLEW_ERROR_GLX_VERSION_11_ONLY; + if (_glewInit_GLX_VERSION_1_2(ctx)) return GLEW_ERROR_GLX_VERSION_11_ONLY; /* query GLX version */ glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); + ctx->__GLXEW_VERSION_1_0 = GL_FALSE; + ctx->__GLXEW_VERSION_1_1 = GL_FALSE; + ctx->__GLXEW_VERSION_1_2 = GL_FALSE; + ctx->__GLXEW_VERSION_1_3 = GL_FALSE; + ctx->__GLXEW_VERSION_1_4 = GL_FALSE; switch (minor) { case 4: - GLXEW_VERSION_1_4 = GL_TRUE; + ctx->__GLXEW_VERSION_1_4 = GL_TRUE; case 3: - GLXEW_VERSION_1_3 = GL_TRUE; + ctx->__GLXEW_VERSION_1_3 = GL_TRUE; case 2: - GLXEW_VERSION_1_2 = GL_TRUE; - GLXEW_VERSION_1_1 = GL_TRUE; - GLXEW_VERSION_1_0 = GL_TRUE; + ctx->__GLXEW_VERSION_1_2 = GL_TRUE; + ctx->__GLXEW_VERSION_1_1 = GL_TRUE; + ctx->__GLXEW_VERSION_1_0 = GL_TRUE; break; default: return GLEW_ERROR_GLX_VERSION_11_ONLY; diff --git a/auto/src/glew_post.c b/auto/src/glew_post.c index fa8534c..9b5b949 100644 --- a/auto/src/glew_post.c +++ b/auto/src/glew_post.c @@ -37,11 +37,11 @@ GLboolean glewExperimental = GL_FALSE; GLenum glewInit () { GLenum r; - if ( (r = _glewInit()) ) return r; + if ( (r = glewContextInit(glewDefaultContext)) ) return r; #if defined(_WIN32) - return _wglewInit(); + return wglewContextInit(wglewDefaultContext); #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ - return _glxewInit(); + return glxewContextInit(glxewDefaultContext); #else return r; #endif /* _WIN32 */ diff --git a/auto/src/glew_post.h b/auto/src/glew_post.h index 4a070a6..71ea982 100644 --- a/auto/src/glew_post.h +++ b/auto/src/glew_post.h @@ -11,8 +11,20 @@ #define GLEW_VERSION 1 /* API */ +#ifdef GLEW_MX +# define GLEW_GET_CONTEXT(x) glewGetContext()->##x +#else +# define GLEW_GET_CONTEXT(x) glewDefaultContext->##x +#endif /* GLEW_MX */ + +typedef struct GLEWContextStruct GLEWContext; + +GLEWAPI GLEWContext* glewDefaultContext; GLEWAPI GLboolean glewExperimental; + GLEWAPI GLenum glewInit (); +GLEWAPI GLenum glewContextInit (GLEWContext* ctx); + GLEWAPI GLboolean glewGetExtension (const GLubyte* name); GLEWAPI const GLubyte* glewGetErrorString (GLenum error); GLEWAPI const GLubyte* glewGetString (GLenum name); @@ -37,6 +49,7 @@ GLEWAPI const GLubyte* glewGetString (GLenum name); #undef WINGDIAPI #endif +/* #undef GLEW_GET_CONTEXT */ #undef GLAPI /* #undef GLEWAPI */ diff --git a/auto/src/glew_pre.c b/auto/src/glew_pre.c index 32cb39b..c4432f6 100644 --- a/auto/src/glew_pre.c +++ b/auto/src/glew_pre.c @@ -94,11 +94,14 @@ static void *dlGetProcAddress (const GLubyte* name) } #endif /* __sgi || __sun */ -/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ +GLEWContext _glewDefaultContext; +GLEWContext* glewDefaultContext = &_glewDefaultContext; -#ifdef GL_VERSION_1_1 - -GLboolean GLEW_VERSION_1_1 = GL_FALSE; - -#endif /* GL_VERSION_1_1 */ +#if defined(_WIN32) +WGLEWContext _wglewDefaultContext; +WGLEWContext* wglewDefaultContext = &_wglewDefaultContext; +#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) +GLXEWContext _glxewDefaultContext; +GLXEWContext* glxewDefaultContext = &_glxewDefaultContext; +#endif diff --git a/auto/src/glew_pre.h b/auto/src/glew_pre.h index c86f653..ec546cf 100644 --- a/auto/src/glew_pre.h +++ b/auto/src/glew_pre.h @@ -1091,11 +1091,11 @@ GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); -GLEWAPI GLboolean GLEW_VERSION_1_1; +#define GLEW_VERSION_1_1 GLEW_GET_CONTEXT(__GLEW_VERSION_1_1) #endif /* GL_VERSION_1_1 */ -/* ------------------------------------------------------------------------- */ +/* ---------------------------------- GLU ---------------------------------- */ /* this is where we can safely include GLU */ #if defined(__APPLE__) && defined(__MACH__) @@ -1104,3 +1104,4 @@ GLEWAPI GLboolean GLEW_VERSION_1_1; #include #endif + diff --git a/auto/src/glew_wgl.c b/auto/src/glew_wgl.c index f9b4965..b596a6d 100644 --- a/auto/src/glew_wgl.c +++ b/auto/src/glew_wgl.c @@ -5,17 +5,18 @@ #ifdef _WIN32 -GLboolean wglewGetExtension (const GLubyte *name) +GLboolean wglewGetExtension (const GLubyte* name) { - GLubyte *p, *end; + GLubyte* p; + GLubyte* end; GLuint len = _glewStrLen(name); - if (wglGetExtensionsStringARB == NULL) - if (wglGetExtensionsStringEXT == NULL) + if (wglewDefaultContext->__wglewGetExtensionsStringARB == NULL) + if (wglewDefaultContext->__wglewGetExtensionsStringEXT == NULL) return GL_FALSE; else - p = (GLubyte*)wglGetExtensionsStringEXT(); + p = (GLubyte*)wglewDefaultContext->__wglewGetExtensionsStringEXT(); else - p = (GLubyte*)wglGetExtensionsStringARB(wglGetCurrentDC()); + p = (GLubyte*)wglewDefaultContext->__wglewGetExtensionsStringARB(wglGetCurrentDC()); if (0 == p) return GL_FALSE; end = p + _glewStrLen(p); while (p < end) @@ -27,13 +28,17 @@ GLboolean wglewGetExtension (const GLubyte *name) return GL_FALSE; } -static GLuint _wglewInit () +GLenum wglewContextInit (WGLEWContext* ctx) { GLboolean crippled; /* find wgl extension string query functions */ - _glewInit_WGL_ARB_extensions_string(); - WGLEW_ARB_extensions_string = wglGetExtensionsStringARB != NULL; - _glewInit_WGL_EXT_extensions_string(); - WGLEW_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; + _glewInit_WGL_ARB_extensions_string(ctx); + ctx->__WGLEW_ARB_extensions_string = (ctx->__wglewGetExtensionsStringARB != NULL); + wglewDefaultContext->__wglewGetExtensionsStringARB = ctx->__wglewGetExtensionsStringARB; + wglewDefaultContext->__WGLEW_ARB_extensions_string = ctx->__WGLEW_ARB_extensions_string; + _glewInit_WGL_EXT_extensions_string(ctx); + ctx->__WGLEW_EXT_extensions_string = (ctx->__wglewGetExtensionsStringEXT != NULL); + wglewDefaultContext->__wglewGetExtensionsStringEXT = ctx->__wglewGetExtensionsStringEXT; + wglewDefaultContext->__WGLEW_EXT_extensions_string = ctx->__WGLEW_EXT_extensions_string; /* initialize extensions */ - crippled = !(WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string); + crippled = !(ctx->__WGLEW_ARB_extensions_string || ctx->__WGLEW_EXT_extensions_string); diff --git a/auto/src/wglew_post.h b/auto/src/wglew_post.h index b1aedd7..7b28023 100644 --- a/auto/src/wglew_post.h +++ b/auto/src/wglew_post.h @@ -1,11 +1,23 @@ /* ------------------------------------------------------------------------- */ +typedef struct WGLEWContextStruct WGLEWContext; +GLEWAPI WGLEWContext* wglewDefaultContext; + +#ifdef GLEW_MX +extern WGLEWContext* wglewGetContext(); +# define WGLEW_GET_CONTEXT(x) wglewGetContext()->##x +#else +# define WGLEW_GET_CONTEXT(x) wglewDefaultContext->##x +#endif /* GLEW_MX */ + +GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx); GLEWAPI GLboolean wglewGetExtension (const GLubyte* name); #ifdef __cplusplus } #endif +/* #undef WGLEW_GET_CONTEXT */ #undef GLEWAPI #endif /* __wglew_h__ */