diff --git a/auto/Makefile b/auto/Makefile index a10d44a..db9a612 100644 --- a/auto/Makefile +++ b/auto/Makefile @@ -242,7 +242,7 @@ $(S.DEST)/glew.c: $(EXT)/.dummy perl -e "s/GLEW_VERSION_MINOR_STRING/$(GLEW_MINOR)/g" -pi $@ perl -e "s/GLEW_VERSION_MICRO_STRING/$(GLEW_MICRO)/g" -pi $@ perl -e "s/GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader\(GLEW_CONTEXT_ARG_VAR_INIT\);/{ GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); _glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); }/g" -pi $@ - perl -e "s/\(\(glColorSubTable = /((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glColorSubTable = /g" -pi $@ + perl -e "s/\(\(glColorSubTable = /((glBlendEquationFP = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glColorSubTable = /g" -pi $@ rm -f $@.bak $(S.DEST)/glew_def.c: $(EXT)/.dummy @@ -297,7 +297,7 @@ $(S.DEST)/glew_init.c: $(EXT)/.dummy perl -e "s/GLEW_VERSION_MINOR_STRING/$(GLEW_MINOR)/g" -pi $@ perl -e "s/GLEW_VERSION_MICRO_STRING/$(GLEW_MICRO)/g" -pi $@ perl -e "s/GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader\(GLEW_CONTEXT_ARG_VAR_INIT\);/{ GLEW_ARB_vertex_shader = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); _glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); }/g" -pi $@ - perl -e "s/\(\(glBlendColor = /((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glBlendColor = /g" -pi $@ + perl -e "s/\(\(glBlendColorFP = /((glBlendEquationFP = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n r = ((glBlendColor = /g" -pi $@ rm -f $@.bak $(S.DEST)/glew_str.c: $(EXT)/.dummy @@ -338,7 +338,7 @@ $(S.DEST)/glewinfo.c: $(EXT)/.dummy $(BIN)/make_info_list.pl $(GLX_CORE_SPEC) >> $@ $(BIN)/make_info_list.pl $(GLX_EXT_SPEC) >> $@ cat $(SRC)/glewinfo_tail.c >> $@ - perl -e 's/"glColorSubTable"/"glBlendEquation", glBlendEquation == NULL);\n glewInfoFunc("glColorSubTable"/g' -pi $@ + perl -e 's/"glColorSubTable"/"glBlendEquation", glBlendEquationFP == NULL);\n glewInfoFunc("glColorSubTable"/g' -pi $@ rm -f $@.bak # Update documentation diff --git a/auto/bin/make_header.pl b/auto/bin/make_header.pl index 934ef77..b3d0e11 100755 --- a/auto/bin/make_header.pl +++ b/auto/bin/make_header.pl @@ -37,7 +37,86 @@ sub make_pfn_type($%) sub make_pfn_alias($%) { our $type; - return join(" ", "#define", $_[0], $type . "EW_GET_FUN(" . prefixname($_[0]) . ")") + my $parms = $_[1]->{parms}; + + #trim off any whitespace + $parms =~ s/^\s+|\s+$//g; + + #fix up parm identifiers for macro + my $fixed_up_parms = ""; + my $fixed_up_calllist = ""; + + #if the parm list is void, nothing to substitute + if(lc($parms) ne "void") + { + #split parms + my @split_parms = split(/,/,$parms); + + my $num_parms = @split_parms; + + my $i = 0; + + foreach(@split_parms) + { + my $temp = $_; + + #remove brackets + $temp =~ s/\[|\]//g; + + #trim off any whitespace + $temp =~ s/^\s+|\s+$//g; + + #get the parm name, store it, and strip it off + my $parm_name = ""; + + if($temp =~ /([a-zA-Z_]+[0-9a-zA-Z_]*)$/) + { + $parm_name = $1; + $temp = substr($temp,0,length($temp) - length($parm_name)); + } + + #remove any remaining whitespace + $temp =~ s/\s+//g; + + #replace pointer * with P + $temp =~ s/\s*\*\s*/P/g; + + #add to parmlist...handling cases where no parm name is specified + if($parm_name eq "") + { + $fixed_up_calllist .= "(" . $temp . "__parm" . $i . ")"; + $fixed_up_parms .= $temp . "__parm" . $i; + } + elsif($temp eq "") + { + $fixed_up_calllist .= "(" . $parm_name . "__parm" . $i . ")"; + $fixed_up_parms .= $parm_name . "__parm" . $i; + } + else + { + $fixed_up_calllist .= "(" . $temp . "__" . $parm_name . ")"; + $fixed_up_parms .= $temp . "__" . $parm_name; + } + + if($i != $num_parms - 1) + { + $fixed_up_parms .= ", "; + $fixed_up_calllist .= ", "; + } + + $i += 1; + } + } + + return join(" ", + #to get the function pointer for assignment/testing + "#define", + $_[0] . "FP", + $type . "EW_GET_FUN(" . prefixname($_[0]) . ")", + #to call the function naturally + "\n#define", + $_[0] . "(" . $fixed_up_parms . ")", + $type . "EW_GET_FUN(" . prefixname($_[0]) . ")(" . $fixed_up_calllist . ")"); } my @extlist = (); diff --git a/auto/bin/make_info.pl b/auto/bin/make_info.pl index 5d0c7f6..5ef1bdc 100755 --- a/auto/bin/make_info.pl +++ b/auto/bin/make_info.pl @@ -18,7 +18,7 @@ do 'bin/make.pl'; sub make_pfn_info($%) { my $name = $_[0]; - return " glewInfoFunc(\"$_[0]\", $name == NULL);"; + return " glewInfoFunc(\"$_[0]\", $name" . "FP == NULL);"; } #--------------------------------------------------------------------------------------- diff --git a/auto/bin/make_init.pl b/auto/bin/make_init.pl index 70abc98..043f074 100755 --- a/auto/bin/make_init.pl +++ b/auto/bin/make_init.pl @@ -18,7 +18,7 @@ do 'bin/make.pl'; sub make_pfn_def_init($%) { #my $name = prefixname($_[0]); - return " r = ((" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; + return " r = ((" . $_[0] . "FP = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;"; } #------------------------------------------------------------------------------- diff --git a/auto/src/glew_init_glx.c b/auto/src/glew_init_glx.c index d160249..72a98b0 100644 --- a/auto/src/glew_init_glx.c +++ b/auto/src/glew_init_glx.c @@ -5,7 +5,7 @@ GLboolean glxewGetExtension (const char* name) const GLubyte* start; const GLubyte* end; - if (glXGetCurrentDisplay == NULL) return GL_FALSE; + if (glXGetCurrentDisplayFP == NULL) return GL_FALSE; start = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (0 == start) return GL_FALSE; end = start + _glewStrLen(start); @@ -45,7 +45,7 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) } /* query GLX extension string */ extStart = 0; - if (glXGetCurrentDisplay != NULL) + if (glXGetCurrentDisplayFP != NULL) extStart = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); if (extStart == 0) extStart = (const GLubyte *)"";