- implemented feature request in sourceforge feature request #30

-- https://sourceforge.net/p/glew/feature-requests/30/
 -- alter macro definitions so that full signature is captured
 -- doubled number of macros to maintain support for function pointer assign/test
 ---- there are some alternate implementations if not desired
 -- seems many signatures don't have parameter names...will look into that
This commit is contained in:
rconde 2014-03-15 17:40:26 -04:00
parent 08196588ed
commit dab1fe8e98
5 changed files with 87 additions and 8 deletions

View File

@ -238,7 +238,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
@ -293,7 +293,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
@ -334,7 +334,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

View File

@ -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($parms ne "void")
{
#split parms
my @split_parms = split(/,/,$parms);
my $num_parms = @split_parms;
my $i = 0;
foreach(@split_parms)
{
my $temp = $_;
#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;
#remove brackets
$temp =~ s/\[|\]//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 = ();

View File

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

View File

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

View File

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