adjust generation code so that the init functions can call other extension loader functions..

- example GL_VERSION_3_0 calling GL_ARB_vertex_array_objects
This commit is contained in:
Edward Rudd 2014-11-21 18:12:06 -05:00
parent b5fce8d088
commit 0b4daf6e55
15 changed files with 54 additions and 16 deletions

View File

@ -12,6 +12,7 @@ my %regex = (
function => qr/^(.+) ([a-z][a-z0-9_]*) \((.+)\)$/i,
token => qr/^([A-Z][A-Z0-9_x]*)\s+((?:0x)?[0-9A-Fa-f]+|[A-Z][A-Z0-9_]*)$/,
type => qr/^typedef\s+(.+)$/,
loadexts => qr/^LOAD (.*)$/,
exact => qr/.*;$/,
);
@ -71,6 +72,7 @@ sub parse_ext($)
my %tokens = ();
my @types = ();
my @exacts = ();
my @loadexts = ();
my $extname = ""; # Full extension name GL_FOO_extension
my $exturl = ""; # Info URL
my $extstring = ""; # Relevant extension string
@ -104,7 +106,11 @@ sub parse_ext($)
chomp;
if (s/^\s+//)
{
if (/$regex{exact}/)
if (/$regex{loadexts}/)
{
push @loadexts, $1;
}
elsif (/$regex{exact}/)
{
push @exacts, $_;
}
@ -132,7 +138,7 @@ sub parse_ext($)
close EXT;
return ($extname, $exturl, $extstring, \@types, \%tokens, \%functions, \@exacts);
return ($extname, $exturl, $extstring, \@types, \%tokens, \%functions, \@exacts, \@loadexts);
}
sub output_tokens($$)
@ -207,3 +213,14 @@ sub output_exacts($$)
}
}
sub output_loadexts($$)
{
my ($tbl, $fnc) = @_;
if (scalar @{$tbl})
{
local $, = "\n";
print "\n";
print map { &{$fnc}($_) } sort @{$tbl};
print "\n";
}
}

View File

@ -29,7 +29,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
output_decls($functions, \&make_pfn_decl);
}
}

View File

@ -23,7 +23,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
print "GLboolean " . prefix_varname($extvar) . " = GL_FALSE;\n";

View File

@ -52,7 +52,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
make_separator($extname);
print "#ifndef $extname\n#define $extname 1\n";

View File

@ -26,7 +26,7 @@ if (@ARGV)
print "<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
$cur_group = $extname;
$cur_group =~ s/^(?:W?)GL(?:X?)_([A-Z0-9]+?)_.*$/$1/;
$extname =~ s/^(?:W?)GL(?:X?)_(.*)$/$1/;

View File

@ -32,7 +32,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
my $extpre = $extname;

View File

@ -38,7 +38,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
print "#ifdef $extname\n";
print " _glewInfo_$extname();\n";

View File

@ -21,6 +21,15 @@ sub make_pfn_def_init($%)
return " r = ((" . $_[0] . " = (PFN" . (uc $_[0]) . "PROC)glewGetProcAddress((const GLubyte*)\"" . $_[0] . "\")) == NULL) || r;";
}
sub make_loadexts_forward($%)
{
return "static GLboolean _glewInit_" . $_[0] . "(GLEW_CONTEXT_ARG_DEF_INIT);";
}
sub make_loadexts_call($%)
{
return " r = _glewInit_" . $_[0] . "(GLEW_CONTEXT_ARG_VAR_INIT) || r;";
}
#-------------------------------------------------------------------------------
my @extlist = ();
@ -34,7 +43,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) =
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) =
parse_ext($ext);
#make_separator($extname);
@ -42,11 +51,14 @@ if (@ARGV)
my $extvar = $extname;
my $extvardef = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
if (keys %$functions)
if (keys %$functions or keys @$loadexts)
{
print "static GLboolean _glewInit_$extname (" . $type .
output_loadexts($loadexts, \&make_loadexts_forward);
print "static GLboolean _glewInit_$extname (" . $type .
"EW_CONTEXT_ARG_DEF_INIT)\n{\n GLboolean r = GL_FALSE;\n";
output_decls($functions, \&make_pfn_def_init);
output_loadexts($loadexts, \&make_loadexts_call);
print "\n return r;\n}\n\n";
}
#print "\nGLboolean " . prefix_varname($extvar) . " = GL_FALSE;\n\n";

View File

@ -32,7 +32,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
@ -49,7 +49,7 @@ if (@ARGV)
print " " . $extvar . " = _glewHashListExists(ext_hashlist, (const GLubyte *)\"$extstring\");\n";
}
if (keys %$functions)
if (keys %$functions or keys @$loadexts)
{
if ($extname =~ /WGL_.*/)
{

View File

@ -22,7 +22,7 @@ if (@ARGV)
my $curexttype = "";
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
my $exttype = $extname;
$exttype =~ s/(W*?)GL(X*?)_(.*?_)(.*)/$3/;
my $extrem = $extname;

View File

@ -30,7 +30,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
output_decls($functions, \&make_pfn_decl);
}
}

View File

@ -23,7 +23,7 @@ if (@ARGV)
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) = parse_ext($ext);
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts, $loadexts) = parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
print $export . " GLboolean " . prefix_varname($extvar) . ";\n";

View File

@ -161,3 +161,7 @@ https://www.opengl.org/registry/doc/glspec30.20080923.pdf
void glClearBufferfv (GLenum buffer, GLint drawBuffer, const GLfloat* value)
void glClearBufferfi (GLenum buffer, GLint drawBuffer, GLfloat depth, GLint stencil)
const GLubyte* glGetStringi (GLenum name, GLuint index)
LOAD GL_ARB_framebuffer_object
LOAD GL_ARB_map_buffer_range
LOAD GL_ARB_uniform_buffer_object
LOAD GL_ARB_vertex_array_object

View File

@ -39,3 +39,4 @@ https://www.opengl.org/registry/doc/glspec31.20090528.pdf
void glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount)
void glTexBuffer (GLenum target, GLenum internalFormat, GLuint buffer)
void glPrimitiveRestartIndex (GLuint buffer)
LOAD GL_ARB_copy_buffer

View File

@ -26,3 +26,7 @@ https://www.opengl.org/registry/doc/glspec32.compatibility.20091207.pdf
void glGetInteger64i_v (GLenum pname, GLuint index, GLint64 * data)
void glGetBufferParameteri64v (GLenum target, GLenum value, GLint64 * data)
void glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level)
LOAD GL_ARB_draw_elements_base_vertex
LOAD GL_ARB_provoking_vertex
LOAD GL_ARB_sync
LOAD GL_ARB_texture_multisample