added glew mx

git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@202 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
ikits 2004-02-01 18:13:05 +00:00
parent 37e20813dc
commit e21be8b86a
16 changed files with 201 additions and 102 deletions

View File

@ -13,7 +13,7 @@ GLEW_VERSION = $(GLEW_MAJOR).$(GLEW_MINOR).$(GLEW_MICRO)
SHELL = bash SHELL = bash
REGISTRY = registry REGISTRY = registry
REGISTRY_URL = http://oss.sgi.com/projects/ogl-sample/registry/ REGISTRY_URL = http://oss.sgi.com/projects/ogl-sample/registry/
BIN = bin BIN = bin
SRC = src SRC = src
CORE = core CORE = core
@ -58,16 +58,20 @@ endif
$(I.DEST)/glew.h: $(EXT)/.dummy $(I.DEST)/glew.h: $(EXT)/.dummy
test -d $(I.DEST) || mkdir -p $(I.DEST) test -d $(I.DEST) || mkdir -p $(I.DEST)
cp -f $(SRC)/glew_pre.h $@ cp -f $(SRC)/glew_pre.h $@
$(BIN)/make_header.pl GLAPIENTRY $(CORE)/GL_VERSION* >> $@ $(BIN)/make_header_def.pl GLAPIENTRY GL $(CORE)/GL_VERSION* >> $@
mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \ # mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \
grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \ # grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \
grep -v 'glBlendEquation' > $@; rm tmp; # grep -v 'glBlendEquation' > $@; rm tmp;
$(BIN)/make_header.pl GLAPIENTRY $(EXT)/GL_* >> $@ $(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 >> $@ cat $(SRC)/glew_post.h >> $@
$(I.DEST)/wglew.h: $(EXT)/.dummy $(I.DEST)/wglew.h: $(EXT)/.dummy
cp -f $(SRC)/wglew_pre.h $@ 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 >> $@ cat $(SRC)/wglew_post.h >> $@
$(I.DEST)/glxew.h: $(EXT)/.dummy $(I.DEST)/glxew.h: $(EXT)/.dummy
@ -79,17 +83,16 @@ $(I.DEST)/glxew.h: $(EXT)/.dummy
$(S.DEST)/glew.c: $(EXT)/.dummy $(S.DEST)/glew.c: $(EXT)/.dummy
cp -f $(SRC)/glew_pre.c $@ cp -f $(SRC)/glew_pre.c $@
$(BIN)/make_init.pl $(CORE)/GL_VERSION* >> $@ $(BIN)/make_init.pl GL $(CORE)/GL_VERSION* >> $@
mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \ # mv $@ tmp; grep -v 'PFNGLBLENDCOLORPROC' tmp | \
grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \ # grep -v 'PFNGLBLENDEQUATIONPROC' | grep -v 'glBlendColor' | \
grep -v 'glBlendEquation' > $@; rm tmp; # grep -v 'glBlendEquation' > $@; rm tmp;
$(BIN)/make_init.pl $(EXT)/GL_* >> $@ $(BIN)/make_init.pl GL $(EXT)/GL_* >> $@
echo -e "#ifdef _WIN32\n" >> $@ echo -e "#ifdef _WIN32\n" >> $@
$(BIN)/make_init.pl $(EXT)/WGL_* >> $@ $(BIN)/make_init.pl WGL $(EXT)/WGL_* >> $@
echo -e "#else /* _UNIX */\n\n" >> $@ echo -e "#else /* _UNIX */\n\n" >> $@
cat $(SRC)/glew_init_glx.c >> $@ $(BIN)/make_init.pl GLX $(CORE)/GLX_VERSION* >> $@
$(BIN)/make_init.pl $(CORE)/GLX_VERSION* >> $@ $(BIN)/make_init.pl GLX $(EXT)/GLX_* >> $@
$(BIN)/make_init.pl $(EXT)/GLX_* >> $@
echo -e "#endif /* _WIN32 */\n" >> $@ echo -e "#endif /* _WIN32 */\n" >> $@
cat $(SRC)/glew_gl.c >> $@ cat $(SRC)/glew_gl.c >> $@

View File

@ -19,7 +19,15 @@ my %regex = (
sub prefixname($) sub prefixname($)
{ {
my $name = $_[0]; 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; return $name;
} }

View File

@ -36,7 +36,7 @@ sub make_pfn_type($%)
# function name alias # function name alias
sub make_pfn_alias($%) sub make_pfn_alias($%)
{ {
return join(" ", "#define", $_[0], prefixname($_[0])) return join(" ", "#define", $_[0], "GLEW_GET_CONTEXT(", $_[0], ")")
} }
# function pointer declaration # function pointer declaration
@ -73,6 +73,7 @@ foreach my $ext (sort @extlist)
my $extvar = $extname; my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/; $extvar =~ s/GL(X*)_/GL$1EW_/;
print "\nGLEWAPI GLboolean $extvar;\n\n"; print "\nGLEWAPI GLboolean _$extvar;\n";
print "#endif /* $extname */\n\n"; print "\n#define $extvar GLEW_GET_CONTEXT($extvar);\n";
print "\n#endif /* $extname */\n\n";
} }

View File

@ -17,7 +17,7 @@ do 'bin/make.pl';
# function pointer definition # function pointer definition
sub make_pfn_info($%) sub make_pfn_info($%)
{ {
my $name = prefixname($_[0]); my $name = $_[0];
return " glewInfoFunc((const GLubyte*)\"$_[0]\", $name == NULL);"; return " glewInfoFunc((const GLubyte*)\"$_[0]\", $name == NULL);";
} }

View File

@ -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 # function pointer definition
sub make_pfn_def_init($%) sub make_pfn_def_init($%)
{ {
my $name = prefixname($_[0]); 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 @extlist = ();
my %extensions = (); my %extensions = ();
our $type = shift;
if (@ARGV) if (@ARGV)
{ {
@extlist = @ARGV; @extlist = @ARGV;
@ -45,21 +41,16 @@ foreach my $ext (sort @extlist)
my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext); my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext);
make_separator($extname); make_separator($extname);
print "#ifdef $extname\n"; print "#ifdef $extname\n\n";
if (keys %$functions)
{
output_decls($functions, \&make_pfn_def);
print "\n";
}
my $extvar = $extname; my $extvar = $extname;
my $extvardef = $extname; my $extvardef = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/; $extvar =~ s/GL(X*)_/GL$1EW_/;
if (keys %$functions) 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); output_decls($functions, \&make_pfn_def_init);
print "\n return r;\n}\n"; 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"; print "#endif /* $extname */\n\n";
} }

View File

@ -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 # function pointer definition
sub make_init_call($%) sub make_init_call($%)
{ {
my $name = prefixname($_[0]); 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; my $extpre = $extname;
$extpre =~ s/^(W?)GL(X?).*$/\l$1gl\l$2ew/; $extpre =~ s/^(W?)GL(X?).*$/\l$1gl\l$2ew/;
my $pextvar = prefix_varname($extvar);
print "#ifdef $extname\n"; 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 (keys %$functions)
{ {
if ($extname =~ /WGL_.*/) 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 else
{ {
print " if (glewExperimental || $extvar) $extvar = !_glewInit_$extname();\n"; print " if (glewExperimental || ctx->" . $pextvar . ") ctx->" . $pextvar . " = !_glewInit_$extname(ctx);\n";
} }
} }
print "#endif /* $extname */\n"; print "#endif /* $extname */\n";

51
auto/bin/make_struct.pl Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/perl
#
# Copyright (C) 2003 Marcelo E. Magallon <mmagallo@debian.org>
# Copyright (C) 2003 Milan Ikits <milan.ikits@ieee.org>
#
# 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";

View File

@ -76,8 +76,6 @@ GL_ARB_imaging
GL_WRAP_BORDER 0x8152 GL_WRAP_BORDER 0x8152
GL_REPLICATE_BORDER 0x8153 GL_REPLICATE_BORDER 0x8153
GL_CONVOLUTION_BORDER_COLOR 0x8154 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 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 glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data)
void glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params) void glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params)

View File

@ -5,21 +5,21 @@
* These functions implement the functionality required in this file. * These functions implement the functionality required in this file.
*/ */
static GLuint _glewStrLen (const GLubyte *s) static GLuint _glewStrLen (const GLubyte* s)
{ {
GLuint i=0; GLuint i=0;
while (s+i != NULL && s[i] != '\0') i++; while (s+i != NULL && s[i] != '\0') i++;
return i; return i;
} }
static GLuint _glewStrCLen (const GLubyte *s, GLubyte c) static GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
{ {
GLuint i=0; GLuint i=0;
while (s+i != NULL && s[i] != '\0' && s[i] != c) i++; while (s+i != NULL && s[i] != '\0' && s[i] != c) i++;
return 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; GLuint i=0;
while (i < n && a+i != NULL && b+i != NULL && a[i] == b[i]) i++; 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 * other extension names. Could use strtok() but the constant
* string returned by glGetString might be in read-only memory. * 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); GLuint len = _glewStrLen(name);
p = (GLubyte*)glGetString(GL_EXTENSIONS); p = (GLubyte*)glGetString(GL_EXTENSIONS);
if (0 == p) return GL_FALSE; 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; const GLubyte* s;
GLuint i; GLuint i;
@ -66,33 +67,43 @@ static GLuint _glewInit ()
{ {
if (s[3] >= '5') if (s[3] >= '5')
{ {
GLEW_VERSION_1_1 = GL_TRUE; ctx->__GLEW_VERSION_1_1 = GL_TRUE;
GLEW_VERSION_1_2 = GL_TRUE; ctx->__GLEW_VERSION_1_2 = GL_TRUE;
GLEW_VERSION_1_3 = GL_TRUE; ctx->__GLEW_VERSION_1_3 = GL_TRUE;
GLEW_VERSION_1_4 = GL_TRUE; ctx->__GLEW_VERSION_1_4 = GL_TRUE;
GLEW_VERSION_1_5 = GL_TRUE; ctx->__GLEW_VERSION_1_5 = GL_TRUE;
} }
if (s[2] == '4') if (s[2] == '4')
{ {
GLEW_VERSION_1_1 = GL_TRUE; ctx->__GLEW_VERSION_1_1 = GL_TRUE;
GLEW_VERSION_1_2 = GL_TRUE; ctx->__GLEW_VERSION_1_2 = GL_TRUE;
GLEW_VERSION_1_3 = GL_TRUE; ctx->__GLEW_VERSION_1_3 = GL_TRUE;
GLEW_VERSION_1_4 = GL_TRUE; ctx->__GLEW_VERSION_1_4 = GL_TRUE;
ctx->__GLEW_VERSION_1_5 = GL_FALSE;
} }
if (s[2] == '3') if (s[2] == '3')
{ {
GLEW_VERSION_1_1 = GL_TRUE; ctx->__GLEW_VERSION_1_1 = GL_TRUE;
GLEW_VERSION_1_2 = GL_TRUE; ctx->__GLEW_VERSION_1_2 = GL_TRUE;
GLEW_VERSION_1_3 = 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') if (s[2] == '2')
{ {
GLEW_VERSION_1_1 = GL_TRUE; ctx->__GLEW_VERSION_1_1 = GL_TRUE;
GLEW_VERSION_1_2 = 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') 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 */ /* initialize extensions */

View File

@ -3,9 +3,10 @@
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ #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); GLuint len = _glewStrLen(name);
if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE;
p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay()));
@ -20,23 +21,28 @@ GLboolean glxewGetExtension (const GLubyte *name)
return GL_FALSE; return GL_FALSE;
} }
static GLuint _glxewInit () GLenum glxewContextInit (GLXEWContext* ctx)
{ {
int major, minor; int major, minor;
/* initialize core GLX 1.2 */ /* 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 */ /* query GLX version */
glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); 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) switch (minor)
{ {
case 4: case 4:
GLXEW_VERSION_1_4 = GL_TRUE; ctx->__GLXEW_VERSION_1_4 = GL_TRUE;
case 3: case 3:
GLXEW_VERSION_1_3 = GL_TRUE; ctx->__GLXEW_VERSION_1_3 = GL_TRUE;
case 2: case 2:
GLXEW_VERSION_1_2 = GL_TRUE; ctx->__GLXEW_VERSION_1_2 = GL_TRUE;
GLXEW_VERSION_1_1 = GL_TRUE; ctx->__GLXEW_VERSION_1_1 = GL_TRUE;
GLXEW_VERSION_1_0 = GL_TRUE; ctx->__GLXEW_VERSION_1_0 = GL_TRUE;
break; break;
default: default:
return GLEW_ERROR_GLX_VERSION_11_ONLY; return GLEW_ERROR_GLX_VERSION_11_ONLY;

View File

@ -37,11 +37,11 @@ GLboolean glewExperimental = GL_FALSE;
GLenum glewInit () GLenum glewInit ()
{ {
GLenum r; GLenum r;
if ( (r = _glewInit()) ) return r; if ( (r = glewContextInit(glewDefaultContext)) ) return r;
#if defined(_WIN32) #if defined(_WIN32)
return _wglewInit(); return wglewContextInit(wglewDefaultContext);
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */
return _glxewInit(); return glxewContextInit(glxewDefaultContext);
#else #else
return r; return r;
#endif /* _WIN32 */ #endif /* _WIN32 */

View File

@ -11,8 +11,20 @@
#define GLEW_VERSION 1 #define GLEW_VERSION 1
/* API */ /* 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 GLboolean glewExperimental;
GLEWAPI GLenum glewInit (); GLEWAPI GLenum glewInit ();
GLEWAPI GLenum glewContextInit (GLEWContext* ctx);
GLEWAPI GLboolean glewGetExtension (const GLubyte* name); GLEWAPI GLboolean glewGetExtension (const GLubyte* name);
GLEWAPI const GLubyte* glewGetErrorString (GLenum error); GLEWAPI const GLubyte* glewGetErrorString (GLenum error);
GLEWAPI const GLubyte* glewGetString (GLenum name); GLEWAPI const GLubyte* glewGetString (GLenum name);
@ -37,6 +49,7 @@ GLEWAPI const GLubyte* glewGetString (GLenum name);
#undef WINGDIAPI #undef WINGDIAPI
#endif #endif
/* #undef GLEW_GET_CONTEXT */
#undef GLAPI #undef GLAPI
/* #undef GLEWAPI */ /* #undef GLEWAPI */

View File

@ -94,11 +94,14 @@ static void *dlGetProcAddress (const GLubyte* name)
} }
#endif /* __sgi || __sun */ #endif /* __sgi || __sun */
/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ GLEWContext _glewDefaultContext;
GLEWContext* glewDefaultContext = &_glewDefaultContext;
#ifdef GL_VERSION_1_1 #if defined(_WIN32)
WGLEWContext _wglewDefaultContext;
GLboolean GLEW_VERSION_1_1 = GL_FALSE; WGLEWContext* wglewDefaultContext = &_wglewDefaultContext;
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
#endif /* GL_VERSION_1_1 */ GLXEWContext _glxewDefaultContext;
GLXEWContext* glxewDefaultContext = &_glxewDefaultContext;
#endif

View File

@ -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 glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); 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 */ #endif /* GL_VERSION_1_1 */
/* ------------------------------------------------------------------------- */ /* ---------------------------------- GLU ---------------------------------- */
/* this is where we can safely include GLU */ /* this is where we can safely include GLU */
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
@ -1104,3 +1104,4 @@ GLEWAPI GLboolean GLEW_VERSION_1_1;
#include <GL/glu.h> #include <GL/glu.h>
#endif #endif

View File

@ -5,17 +5,18 @@
#ifdef _WIN32 #ifdef _WIN32
GLboolean wglewGetExtension (const GLubyte *name) GLboolean wglewGetExtension (const GLubyte* name)
{ {
GLubyte *p, *end; GLubyte* p;
GLubyte* end;
GLuint len = _glewStrLen(name); GLuint len = _glewStrLen(name);
if (wglGetExtensionsStringARB == NULL) if (wglewDefaultContext->__wglewGetExtensionsStringARB == NULL)
if (wglGetExtensionsStringEXT == NULL) if (wglewDefaultContext->__wglewGetExtensionsStringEXT == NULL)
return GL_FALSE; return GL_FALSE;
else else
p = (GLubyte*)wglGetExtensionsStringEXT(); p = (GLubyte*)wglewDefaultContext->__wglewGetExtensionsStringEXT();
else else
p = (GLubyte*)wglGetExtensionsStringARB(wglGetCurrentDC()); p = (GLubyte*)wglewDefaultContext->__wglewGetExtensionsStringARB(wglGetCurrentDC());
if (0 == p) return GL_FALSE; if (0 == p) return GL_FALSE;
end = p + _glewStrLen(p); end = p + _glewStrLen(p);
while (p < end) while (p < end)
@ -27,13 +28,17 @@ GLboolean wglewGetExtension (const GLubyte *name)
return GL_FALSE; return GL_FALSE;
} }
static GLuint _wglewInit () GLenum wglewContextInit (WGLEWContext* ctx)
{ {
GLboolean crippled; GLboolean crippled;
/* find wgl extension string query functions */ /* find wgl extension string query functions */
_glewInit_WGL_ARB_extensions_string(); _glewInit_WGL_ARB_extensions_string(ctx);
WGLEW_ARB_extensions_string = wglGetExtensionsStringARB != NULL; ctx->__WGLEW_ARB_extensions_string = (ctx->__wglewGetExtensionsStringARB != NULL);
_glewInit_WGL_EXT_extensions_string(); wglewDefaultContext->__wglewGetExtensionsStringARB = ctx->__wglewGetExtensionsStringARB;
WGLEW_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; 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 */ /* initialize extensions */
crippled = !(WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string); crippled = !(ctx->__WGLEW_ARB_extensions_string || ctx->__WGLEW_EXT_extensions_string);

View File

@ -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); GLEWAPI GLboolean wglewGetExtension (const GLubyte* name);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* #undef WGLEW_GET_CONTEXT */
#undef GLEWAPI #undef GLEWAPI
#endif /* __wglew_h__ */ #endif /* __wglew_h__ */