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

@ -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 >> $@

View File

@ -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;
}

View File

@ -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";
}

View File

@ -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);";
}

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
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";
}

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
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;";
}
#---------------------------------------------------------------------------------------
@ -50,17 +44,19 @@ 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";

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_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)

View File

@ -34,7 +34,8 @@ static GLboolean _glewStrSame (const GLubyte *a, const GLubyte *b, GLuint n)
*/
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 */

View File

@ -5,7 +5,8 @@
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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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

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 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 <GL/glu.h>
#endif

View File

@ -7,15 +7,16 @@
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);

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);
#ifdef __cplusplus
}
#endif
/* #undef WGLEW_GET_CONTEXT */
#undef GLEWAPI
#endif /* __wglew_h__ */