mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-26 16:41:57 +00:00
added binary compatibility for the single pipe version (through global variables) -- GLEW_MX is not a compilation switch
git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@227 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
parent
5b254ad20a
commit
4d82054139
@ -62,7 +62,7 @@ $(I.DEST)/glew.h: $(EXT)/.dummy
|
|||||||
$(BIN)/make_header.pl GLAPIENTRY GL $(CORE)/GL_VERSION* >> $@
|
$(BIN)/make_header.pl GLAPIENTRY GL $(CORE)/GL_VERSION* >> $@
|
||||||
$(BIN)/make_header.pl GLAPIENTRY GL $(EXT)/GL_* >> $@
|
$(BIN)/make_header.pl GLAPIENTRY GL $(EXT)/GL_* >> $@
|
||||||
$(BIN)/make_struct.pl GL $(CORE)/GL_VERSION* $(EXT)/GL_* >> $@
|
$(BIN)/make_struct.pl GL $(CORE)/GL_VERSION* $(EXT)/GL_* >> $@
|
||||||
perl -e 's/ GLboolean __GLEW_VERSION_1_2;/ GLboolean __GLEW_VERSION_1_1;\n GLboolean __GLEW_VERSION_1_2;/' -pi.bak $@
|
perl -e 's/GLEW_EXPORT GLboolean __GLEW_VERSION_1_2;/GLEW_EXPORT GLboolean __GLEW_VERSION_1_1;\nGLEW_EXPORT GLboolean __GLEW_VERSION_1_2;/' -pi.bak $@
|
||||||
rm -f $@.bak
|
rm -f $@.bak
|
||||||
cat $(SRC)/glew_post.h >> $@
|
cat $(SRC)/glew_post.h >> $@
|
||||||
|
|
||||||
@ -83,6 +83,14 @@ $(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_struct_def.pl GL $(CORE)/GL_VERSION* $(EXT)/GL_* >> $@
|
||||||
|
echo -e "\n#endif /* !_WIN32 || !GLEW_MX */\n" >> $@
|
||||||
|
echo -e "#if defined(_WIN32) && !defined(GLEW_MX)" >> $@
|
||||||
|
$(BIN)/make_struct_def.pl WGL $(EXT)/WGL_* >> $@
|
||||||
|
echo -e "\n#endif /* _WIN32 && !GLEW_MX */\n" >> $@
|
||||||
|
echo -e "#if !(defined(_WIN32) || (defined(__APPLE__) && !defined(GLEW_APPLE_GLX)))" >> $@
|
||||||
|
$(BIN)/make_struct_def.pl GLX $(EXT)/GLX_* >> $@
|
||||||
|
echo -e "\n#endif /* !_WIN32 */\n" >> $@
|
||||||
$(BIN)/make_init.pl GL $(CORE)/GL_VERSION* >> $@
|
$(BIN)/make_init.pl GL $(CORE)/GL_VERSION* >> $@
|
||||||
$(BIN)/make_init.pl GL $(EXT)/GL_* >> $@
|
$(BIN)/make_init.pl GL $(EXT)/GL_* >> $@
|
||||||
echo -e "#ifdef _WIN32\n" >> $@
|
echo -e "#ifdef _WIN32\n" >> $@
|
||||||
|
@ -37,13 +37,7 @@ sub make_pfn_type($%)
|
|||||||
sub make_pfn_alias($%)
|
sub make_pfn_alias($%)
|
||||||
{
|
{
|
||||||
our $type;
|
our $type;
|
||||||
return join(" ", "#define", $_[0], $type . "EW_GET_CONTEXT(" . prefixname($_[0]) . ")")
|
return join(" ", "#define", $_[0], $type . "EW_GET_FUN(" . prefixname($_[0]) . ")")
|
||||||
}
|
|
||||||
|
|
||||||
# function pointer declaration
|
|
||||||
sub make_pfn_decl($%)
|
|
||||||
{
|
|
||||||
return "GLEWAPI PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . ";";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my @extlist = ();
|
my @extlist = ();
|
||||||
@ -70,12 +64,11 @@ foreach my $ext (sort @extlist)
|
|||||||
output_types($types, \&make_type);
|
output_types($types, \&make_type);
|
||||||
output_exacts($exacts, \&make_exact);
|
output_exacts($exacts, \&make_exact);
|
||||||
output_decls($functions, \&make_pfn_type);
|
output_decls($functions, \&make_pfn_type);
|
||||||
#output_decls($functions, \&make_pfn_decl);
|
|
||||||
output_decls($functions, \&make_pfn_alias);
|
output_decls($functions, \&make_pfn_alias);
|
||||||
|
|
||||||
my $extvar = $extname;
|
my $extvar = $extname;
|
||||||
$extvar =~ s/GL(X*)_/GL$1EW_/;
|
$extvar =~ s/GL(X*)_/GL$1EW_/;
|
||||||
|
|
||||||
print "\n#define $extvar " . $type . "EW_GET_CONTEXT(" . prefix_varname($extvar) . ")\n";
|
print "\n#define $extvar " . $type . "EW_GET_VAR(" . prefix_varname($extvar) . ")\n";
|
||||||
print "\n#endif /* $extname */\n\n";
|
print "\n#endif /* $extname */\n\n";
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,16 @@ use warnings;
|
|||||||
|
|
||||||
do 'bin/make.pl';
|
do 'bin/make.pl';
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 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 = ((ctx->" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;";
|
return " r = ((" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;";
|
||||||
}
|
}
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
my @extlist = ();
|
my @extlist = ();
|
||||||
my %extensions = ();
|
my %extensions = ();
|
||||||
@ -38,7 +38,8 @@ if (@ARGV)
|
|||||||
|
|
||||||
foreach my $ext (sort @extlist)
|
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\n";
|
print "#ifdef $extname\n\n";
|
||||||
@ -47,7 +48,8 @@ foreach my $ext (sort @extlist)
|
|||||||
$extvar =~ s/GL(X*)_/GL$1EW_/;
|
$extvar =~ s/GL(X*)_/GL$1EW_/;
|
||||||
if (keys %$functions)
|
if (keys %$functions)
|
||||||
{
|
{
|
||||||
print "static GLboolean _glewInit_$extname (" . $type . "EWContext* ctx)\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";
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ do 'bin/make.pl';
|
|||||||
sub make_init_call($%)
|
sub make_init_call($%)
|
||||||
{
|
{
|
||||||
my $name = prefixname($_[0]);
|
my $name = prefixname($_[0]);
|
||||||
return " r = r || (ctx->" . $name . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;";
|
return " r = r || (" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress(\"" . $name . "\")) == NULL;";
|
||||||
}
|
}
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------
|
||||||
@ -44,19 +44,19 @@ 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);
|
#my $pextvar = prefix_varname($extvar);
|
||||||
|
|
||||||
print "#ifdef $extname\n";
|
print "#ifdef $extname\n";
|
||||||
print " ctx->" . $pextvar . "= " . $extpre . "GetExtension(\"$extname\");\n";
|
print " " . $extvar . "= " . $extpre . "GetExtension(\"$extname\");\n";
|
||||||
if (keys %$functions)
|
if (keys %$functions)
|
||||||
{
|
{
|
||||||
if ($extname =~ /WGL_.*/)
|
if ($extname =~ /WGL_.*/)
|
||||||
{
|
{
|
||||||
print " if (glewExperimental || ctx->" . $pextvar . "|| crippled) ctx->" . $pextvar . "= !_glewInit_$extname(ctx);\n";
|
print " if (glewExperimental || " . $extvar . "|| crippled) " . $extvar . "= !_glewInit_$extname(ctx);\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print " if (glewExperimental || ctx->" . $pextvar . ") ctx->" . $pextvar . " = !_glewInit_$extname(ctx);\n";
|
print " if (glewExperimental || " . $extvar . ") " . $extvar . " = !_glewInit_$extname(ctx);\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "#endif /* $extname */\n";
|
print "#endif /* $extname */\n";
|
||||||
|
@ -15,7 +15,7 @@ do 'bin/make.pl';
|
|||||||
# function pointer declaration
|
# function pointer declaration
|
||||||
sub make_pfn_decl($%)
|
sub make_pfn_decl($%)
|
||||||
{
|
{
|
||||||
return " PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . ";";
|
return "GLEW_EXPORT PFN" . (uc $_[0]) . "PROC " . prefixname($_[0]) . ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
my @extlist = ();
|
my @extlist = ();
|
||||||
@ -32,7 +32,14 @@ if (@ARGV)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print "/* ------------------------------------------------------------------------- */\n\n";
|
print "/* ------------------------------------------------------------------------- */\n\n";
|
||||||
print "struct " . $type . "EWContextStruct\n{";
|
print "#ifdef GLEW_MX\n";
|
||||||
|
print "#define GLEW_EXPORT\n";
|
||||||
|
print "#else\n";
|
||||||
|
print "#define GLEW_EXPORT GLEWAPI\n";
|
||||||
|
print "#endif /* GLEW_MX */\n\n";
|
||||||
|
print "#if defined(GLEW_MX) && defined(_WIN32)\n";
|
||||||
|
print "struct " . $type . "EWContextStruct\n{\n";
|
||||||
|
print "#endif /* GLEW_MX */\n";
|
||||||
|
|
||||||
foreach my $ext (sort @extlist)
|
foreach my $ext (sort @extlist)
|
||||||
{
|
{
|
||||||
@ -40,14 +47,18 @@ foreach my $ext (sort @extlist)
|
|||||||
output_decls($functions, \&make_pfn_decl);
|
output_decls($functions, \&make_pfn_decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n";
|
print "\n#if defined(GLEW_MX) && !defined(_WIN32)\n";
|
||||||
|
print "struct " . $type . "EWContextStruct\n{\n";
|
||||||
|
print "#endif /* GLEW_MX */\n\n";
|
||||||
|
|
||||||
foreach my $ext (sort @extlist)
|
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);
|
||||||
my $extvar = $extname;
|
my $extvar = $extname;
|
||||||
$extvar =~ s/GL(X*)_/GL$1EW_/;
|
$extvar =~ s/GL(X*)_/GL$1EW_/;
|
||||||
print " GLboolean " . prefix_varname($extvar) . ";\n";
|
print "GLEW_EXPORT GLboolean " . prefix_varname($extvar) . ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n}; /* " . $type . "EWContextStruct */\n\n";
|
print "\n#ifdef GLEW_MX\n";
|
||||||
|
print "}; /* " . $type . "EWContextStruct */\n";
|
||||||
|
print "#endif /* GLEW_MX */\n\n";
|
||||||
|
@ -51,6 +51,9 @@ GLboolean glewGetExtension (const char* name)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef GLEW_MX
|
||||||
|
static
|
||||||
|
#endif
|
||||||
GLenum glewContextInit (GLEWContext* ctx)
|
GLenum glewContextInit (GLEWContext* ctx)
|
||||||
{
|
{
|
||||||
const GLubyte* s;
|
const GLubyte* s;
|
||||||
@ -67,43 +70,43 @@ GLenum glewContextInit (GLEWContext* ctx)
|
|||||||
{
|
{
|
||||||
if (s[3] >= '5')
|
if (s[3] >= '5')
|
||||||
{
|
{
|
||||||
ctx->__GLEW_VERSION_1_1 = GL_TRUE;
|
GLEW_VERSION_1_1 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_2 = GL_TRUE;
|
GLEW_VERSION_1_2 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_3 = GL_TRUE;
|
GLEW_VERSION_1_3 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_4 = GL_TRUE;
|
GLEW_VERSION_1_4 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_5 = GL_TRUE;
|
GLEW_VERSION_1_5 = GL_TRUE;
|
||||||
}
|
}
|
||||||
if (s[2] == '4')
|
if (s[2] == '4')
|
||||||
{
|
{
|
||||||
ctx->__GLEW_VERSION_1_1 = GL_TRUE;
|
GLEW_VERSION_1_1 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_2 = GL_TRUE;
|
GLEW_VERSION_1_2 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_3 = GL_TRUE;
|
GLEW_VERSION_1_3 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_4 = GL_TRUE;
|
GLEW_VERSION_1_4 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_5 = GL_FALSE;
|
GLEW_VERSION_1_5 = GL_FALSE;
|
||||||
}
|
}
|
||||||
if (s[2] == '3')
|
if (s[2] == '3')
|
||||||
{
|
{
|
||||||
ctx->__GLEW_VERSION_1_1 = GL_TRUE;
|
GLEW_VERSION_1_1 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_2 = GL_TRUE;
|
GLEW_VERSION_1_2 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_3 = GL_TRUE;
|
GLEW_VERSION_1_3 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_4 = GL_FALSE;
|
GLEW_VERSION_1_4 = GL_FALSE;
|
||||||
ctx->__GLEW_VERSION_1_5 = GL_FALSE;
|
GLEW_VERSION_1_5 = GL_FALSE;
|
||||||
}
|
}
|
||||||
if (s[2] == '2')
|
if (s[2] == '2')
|
||||||
{
|
{
|
||||||
ctx->__GLEW_VERSION_1_1 = GL_TRUE;
|
GLEW_VERSION_1_1 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_2 = GL_TRUE;
|
GLEW_VERSION_1_2 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_3 = GL_FALSE;
|
GLEW_VERSION_1_3 = GL_FALSE;
|
||||||
ctx->__GLEW_VERSION_1_4 = GL_FALSE;
|
GLEW_VERSION_1_4 = GL_FALSE;
|
||||||
ctx->__GLEW_VERSION_1_5 = GL_FALSE;
|
GLEW_VERSION_1_5 = GL_FALSE;
|
||||||
}
|
}
|
||||||
if (s[2] < '2')
|
if (s[2] < '2')
|
||||||
{
|
{
|
||||||
ctx->__GLEW_VERSION_1_1 = GL_TRUE;
|
GLEW_VERSION_1_1 = GL_TRUE;
|
||||||
ctx->__GLEW_VERSION_1_2 = GL_FALSE;
|
GLEW_VERSION_1_2 = GL_FALSE;
|
||||||
ctx->__GLEW_VERSION_1_3 = GL_FALSE;
|
GLEW_VERSION_1_3 = GL_FALSE;
|
||||||
ctx->__GLEW_VERSION_1_4 = GL_FALSE;
|
GLEW_VERSION_1_4 = GL_FALSE;
|
||||||
ctx->__GLEW_VERSION_1_5 = GL_FALSE;
|
GLEW_VERSION_1_5 = GL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* initialize extensions */
|
/* initialize extensions */
|
||||||
|
@ -8,8 +8,8 @@ GLboolean glxewGetExtension (const char* name)
|
|||||||
GLubyte* p;
|
GLubyte* p;
|
||||||
GLubyte* end;
|
GLubyte* end;
|
||||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||||
if (glXQueryExtensionsString == NULL || glxewDefaultContext->__glewXGetCurrentDisplay == NULL) return GL_FALSE;
|
if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE;
|
||||||
p = (GLubyte*)glXQueryExtensionsString(glxewDefaultContext->__glewXGetCurrentDisplay(), DefaultScreen(glxewDefaultContext->__glewXGetCurrentDisplay()));
|
p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay()));
|
||||||
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)
|
||||||
@ -21,29 +21,32 @@ GLboolean glxewGetExtension (const char* name)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GLEW_MX
|
||||||
|
static
|
||||||
|
#endif
|
||||||
GLenum glxewContextInit (GLXEWContext* ctx)
|
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(ctx)) return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
if (_glewInit_GLX_VERSION_1_2(ctx)) return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
||||||
glxewDefaultContext->__glewXGetCurrentDisplay = ctx->__glewXGetCurrentDisplay;
|
/* initialize flags */
|
||||||
|
GLXEW_VERSION_1_0 = GL_FALSE;
|
||||||
|
GLXEW_VERSION_1_1 = GL_FALSE;
|
||||||
|
GLXEW_VERSION_1_2 = GL_FALSE;
|
||||||
|
GLXEW_VERSION_1_3 = GL_FALSE;
|
||||||
|
GLXEW_VERSION_1_4 = GL_FALSE;
|
||||||
/* 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:
|
||||||
ctx->__GLXEW_VERSION_1_4 = GL_TRUE;
|
GLXEW_VERSION_1_4 = GL_TRUE;
|
||||||
case 3:
|
case 3:
|
||||||
ctx->__GLXEW_VERSION_1_3 = GL_TRUE;
|
GLXEW_VERSION_1_3 = GL_TRUE;
|
||||||
case 2:
|
case 2:
|
||||||
ctx->__GLXEW_VERSION_1_2 = GL_TRUE;
|
GLXEW_VERSION_1_2 = GL_TRUE;
|
||||||
ctx->__GLXEW_VERSION_1_1 = GL_TRUE;
|
GLXEW_VERSION_1_1 = GL_TRUE;
|
||||||
ctx->__GLXEW_VERSION_1_0 = GL_TRUE;
|
GLXEW_VERSION_1_0 = GL_TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
||||||
|
@ -34,15 +34,23 @@ const GLubyte* glewGetString (GLenum name)
|
|||||||
|
|
||||||
GLboolean glewExperimental = GL_FALSE;
|
GLboolean glewExperimental = GL_FALSE;
|
||||||
|
|
||||||
|
#ifndef GLEW_MX
|
||||||
|
|
||||||
GLenum glewInit ()
|
GLenum glewInit ()
|
||||||
{
|
{
|
||||||
GLenum r;
|
GLenum r;
|
||||||
if ( (r = glewContextInit(glewDefaultContext)) ) return r;
|
if ( (r = glewContextInit(0)) ) return r;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return wglewContextInit(wglewDefaultContext);
|
return wglewContextInit(0);
|
||||||
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */
|
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */
|
||||||
return glxewContextInit(glxewDefaultContext);
|
return glxewContextInit(0);
|
||||||
#else
|
#else
|
||||||
return r;
|
return r;
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -12,19 +12,28 @@
|
|||||||
|
|
||||||
/* API */
|
/* API */
|
||||||
#ifdef GLEW_MX
|
#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;
|
typedef struct GLEWContextStruct GLEWContext;
|
||||||
|
|
||||||
GLEWAPI GLEWContext* glewDefaultContext;
|
|
||||||
GLEWAPI GLboolean glewExperimental;
|
|
||||||
|
|
||||||
GLEWAPI GLenum glewInit ();
|
|
||||||
GLEWAPI GLenum glewContextInit (GLEWContext* ctx);
|
GLEWAPI GLenum glewContextInit (GLEWContext* ctx);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define GLEW_GET_VAR(x) glewGetContext()->x
|
||||||
|
# define GLEW_GET_FUN(x) glewGetContext()->x
|
||||||
|
#else
|
||||||
|
# define GLEW_GET_VAR(x) glewGetContext()->x
|
||||||
|
# define GLEW_GET_FUN(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* GLEW_MX */
|
||||||
|
|
||||||
|
GLEWAPI GLenum glewInit ();
|
||||||
|
|
||||||
|
#define GLEW_GET_VAR(x) x
|
||||||
|
#define GLEW_GET_FUN(x) x
|
||||||
|
|
||||||
|
#endif /* GLEW_MX */
|
||||||
|
|
||||||
|
GLEWAPI GLboolean glewExperimental;
|
||||||
GLEWAPI GLboolean glewGetExtension (const char* name);
|
GLEWAPI GLboolean glewGetExtension (const char* 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);
|
||||||
@ -49,7 +58,6 @@ GLEWAPI const GLubyte* glewGetString (GLenum name);
|
|||||||
#undef WINGDIAPI
|
#undef WINGDIAPI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #undef GLEW_GET_CONTEXT */
|
|
||||||
#undef GLAPI
|
#undef GLAPI
|
||||||
/* #undef GLEWAPI */
|
/* #undef GLEWAPI */
|
||||||
|
|
||||||
|
@ -94,14 +94,15 @@ static void *dlGetProcAddress (const GLubyte* name)
|
|||||||
}
|
}
|
||||||
#endif /* __sgi || __sun */
|
#endif /* __sgi || __sun */
|
||||||
|
|
||||||
GLEWContext _glewDefaultContext;
|
#ifdef GLEW_MX
|
||||||
GLEWContext* glewDefaultContext = &_glewDefaultContext;
|
#define glewGetContext() ctx
|
||||||
|
#else
|
||||||
#if defined(_WIN32)
|
#define GLEWContext void
|
||||||
WGLEWContext _wglewDefaultContext;
|
#define WGLEWContext void
|
||||||
WGLEWContext* wglewDefaultContext = &_wglewDefaultContext;
|
#define GLXEWContext void
|
||||||
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
|
||||||
GLXEWContext _glxewDefaultContext;
|
|
||||||
GLXEWContext* glxewDefaultContext = &_glxewDefaultContext;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32) || !defined(GLEW_MX)
|
||||||
|
|
||||||
|
GLboolean __GLEW_VERSION_1_1 = GL_FALSE;
|
||||||
|
|
||||||
|
@ -1091,7 +1091,7 @@ 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);
|
||||||
|
|
||||||
#define GLEW_VERSION_1_1 GLEW_GET_CONTEXT(__GLEW_VERSION_1_1)
|
#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1)
|
||||||
|
|
||||||
#endif /* GL_VERSION_1_1 */
|
#endif /* GL_VERSION_1_1 */
|
||||||
|
|
||||||
|
@ -5,18 +5,21 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
static PFNWGLGETEXTENSIONSSTRINGARBPROC _wglewGetExtensionsStringARB = NULL;
|
||||||
|
static PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL;
|
||||||
|
|
||||||
GLboolean wglewGetExtension (const char* name)
|
GLboolean wglewGetExtension (const char* name)
|
||||||
{
|
{
|
||||||
GLubyte* p;
|
GLubyte* p;
|
||||||
GLubyte* end;
|
GLubyte* end;
|
||||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||||
if (wglewDefaultContext->__wglewGetExtensionsStringARB == NULL)
|
if (_wglewGetExtensionsStringARB == NULL)
|
||||||
if (wglewDefaultContext->__wglewGetExtensionsStringEXT == NULL)
|
if (_wglewGetExtensionsStringEXT == NULL)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
else
|
else
|
||||||
p = (GLubyte*)wglewDefaultContext->__wglewGetExtensionsStringEXT();
|
p = (GLubyte*)_wglewGetExtensionsStringEXT();
|
||||||
else
|
else
|
||||||
p = (GLubyte*)wglewDefaultContext->__wglewGetExtensionsStringARB(wglGetCurrentDC());
|
p = (GLubyte*)_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)
|
||||||
@ -28,17 +31,16 @@ GLboolean wglewGetExtension (const char* name)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GLEW_MX
|
||||||
|
static
|
||||||
|
#endif
|
||||||
GLenum wglewContextInit (WGLEWContext* ctx)
|
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(ctx);
|
if (_wglewGetExtensionsStringARB == NULL)
|
||||||
ctx->__WGLEW_ARB_extensions_string = (ctx->__wglewGetExtensionsStringARB != NULL);
|
_wglewGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB");
|
||||||
wglewDefaultContext->__wglewGetExtensionsStringARB = ctx->__wglewGetExtensionsStringARB;
|
if (_wglewGetExtensionsStringEXT == NULL)
|
||||||
wglewDefaultContext->__WGLEW_ARB_extensions_string = ctx->__WGLEW_ARB_extensions_string;
|
_wglewGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT");
|
||||||
_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 = !(ctx->__WGLEW_ARB_extensions_string || ctx->__WGLEW_EXT_extensions_string);
|
crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL;
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
typedef struct GLXEWContextStruct GLXEWContext;
|
|
||||||
GLEWAPI GLXEWContext* glxewDefaultContext;
|
|
||||||
|
|
||||||
#ifdef GLEW_MX
|
#ifdef GLEW_MX
|
||||||
extern GLXEWContext* glxewGetContext();
|
|
||||||
# define GLXEW_GET_CONTEXT(x) glxewGetContext()->x
|
typedef struct GLXEWContextStruct GLXEWContext;
|
||||||
#else
|
extern GLenum glxewContextInit (GLXEWContext* ctx);
|
||||||
# define GLXEW_GET_CONTEXT(x) glxewDefaultContext->x
|
|
||||||
|
#define GLXEW_GET_VAR(x) glxewGetContext()->x
|
||||||
|
#define GLXEW_GET_FUN(x) x
|
||||||
|
|
||||||
|
#else /* GLEW_MX */
|
||||||
|
|
||||||
|
#define GLXEW_GET_VAR(x) x
|
||||||
|
#define GLXEW_GET_FUN(x) x
|
||||||
|
|
||||||
#endif /* GLEW_MX */
|
#endif /* GLEW_MX */
|
||||||
|
|
||||||
extern GLenum glxewContextInit (GLXEWContext* ctx);
|
|
||||||
extern GLboolean glxewGetExtension (const char* name);
|
extern GLboolean glxewGetExtension (const char* name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct WGLEWContextStruct WGLEWContext;
|
|
||||||
GLEWAPI WGLEWContext* wglewDefaultContext;
|
|
||||||
|
|
||||||
#ifdef GLEW_MX
|
#ifdef GLEW_MX
|
||||||
extern WGLEWContext* wglewGetContext();
|
|
||||||
# define WGLEW_GET_CONTEXT(x) wglewGetContext()->x
|
typedef struct WGLEWContextStruct WGLEWContext;
|
||||||
#else
|
GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx);
|
||||||
# define WGLEW_GET_CONTEXT(x) wglewDefaultContext->x
|
|
||||||
|
#define WGLEW_GET_VAR(x) wglewGetContext()->x
|
||||||
|
#define WGLEW_GET_FUN(x) wglewGetContext()->x
|
||||||
|
|
||||||
|
#else /* GLEW_MX */
|
||||||
|
|
||||||
|
#define WGLEW_GET_VAR(x) x
|
||||||
|
#define WGLEW_GET_FUN(x) x
|
||||||
|
|
||||||
#endif /* GLEW_MX */
|
#endif /* GLEW_MX */
|
||||||
|
|
||||||
GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx);
|
|
||||||
GLEWAPI GLboolean wglewGetExtension (const char* name);
|
GLEWAPI GLboolean wglewGetExtension (const char* name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #undef WGLEW_GET_CONTEXT */
|
|
||||||
#undef GLEWAPI
|
#undef GLEWAPI
|
||||||
|
|
||||||
#endif /* __wglew_h__ */
|
#endif /* __wglew_h__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user