Commit bff705dc authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

New OpenGL thunk generation script.

parent ef275bbb
#!/usr/bin/perl -w
print "
/* Auto-generated file... Do not edit ! */
#include \"config.h\"
#include \"wine_gl.h\"
#include \"opengl_ext.h\"
";
#
# First, create a hash-table with all function defined in opengl32.spec
#
%opengl_std = ();
open(SPEC, "dlls/opengl32/opengl32.spec") || die "Could not open spec file";
foreach (<SPEC>) {
if (($_ =~ /@/) && ($_ !~ /wgl/)) {
($name) = ($_ =~ /stdcall (\w*)\(/);
$opengl_std{$name} = 1;
}
}
close(SPEC);
#
# Now, the functions from the include file
#
%opengl_ext = ();
open(INC, "/home/ulmer/OpenGL/glext_proto.h") || die "Could not open GL/glext.h";
while ($line = <INC>) {
if ($line =~ /extern.*APIENTRY/) {
# Start of a function declaration
($ret, $name, $args) = ($line =~ /extern (\w*) APIENTRY *(\w*) *\((.*)\)/);
# Now, remove all function already defined in opengl32.spec
if ($opengl_std{$name}) {
# Do nothing as we already have these functions
} else {
# Now, get the typedef name (the line after)
($typedef_name) = (<INC> =~ /\(APIENTRY *\* *(\w*) *\)/);
# After that, parse the arguments
@args = split /,/, $args;
$args_ref = [];
foreach (@args) {
push @$args_ref, $_;
}
$opengl_ext{$name} = [ $ret, $typedef_name, $args_ref ];
}
}
}
close(INC);
#
# After that, generate the file itself....
#
print "/* These will be filled during a wglGetProcAddress call */\n";
$num = 0;
foreach $name (sort keys(%opengl_ext)) {
$ref = $opengl_ext{$name};
$arg_ref = $$ref[2];
@larg = @$arg_ref;
print "$$ref[0] (*func_$name)(";
$farg = shift @larg;
print "$farg";
foreach (@larg) {
print ", $_";
}
print ") = (void *) 0xdeadbeef;\n";
$num++;
}
print "\n";
print "/* The function prototypes */\n";
foreach $name (sort keys(%opengl_ext)) {
$ref = $opengl_ext{$name};
$arg_ref = $$ref[2];
@larg = @$arg_ref;
print "$$ref[0] WINAPI wine_$name(";
$farg = shift @larg;
print "$farg";
foreach (@larg) {
print ", $_";
}
print ") ;\n";
}
print "\n";
print "/* The table giving the correspondance between names and functions */\n";
print "int extension_registry_size = $num;\n";
print "OpenGL_extension extension_registry[] = {\n";
foreach $name (sort keys(%opengl_ext)) {
$num--;
print " { \"$name\", (void *) wine_$name, (void **) (&func_$name) }";
if ($num) {
print ",";
}
print "\n";
}
print "};\n";
print "\n";
print "/* Now, the function declarations */\n";
foreach $name (sort keys(%opengl_ext)) {
$ref = $opengl_ext{$name};
$arg_ref = $$ref[2];
print "$$ref[0] WINAPI wine_$name(";
$farg = shift @$arg_ref;
$num = 0;
if ($farg !~ /void/) {
print "$farg arg_0";
$num++;
foreach (@$arg_ref) {
print ", $_ arg_$num";
$num++;
}
}
print ") {\n";
if ($$ref[0] !~ /void/) {
print " $$ref[0] ret;\n"
}
print " ENTER_GL();\n";
print " ";
if ($$ref[0] !~ /void/) {
print " ret = ";
}
print "func_$name(";
if ($num > 0) {
print "arg_0";
for ($i = 1; $i < $num; $i++) {
print ", arg_$i";
}
}
print ");\n";
print " LEAVE_GL();\n";
if ($$ref[0] !~ /void/) {
print " return ret;\n"
}
print "}\n\n";
}
#!/usr/bin/perl -w
print "
/* Auto-generated file... Do not edit ! */
#include \"config.h\"
#include \"wine_gl.h\"
";
#
# Now, the functions from the include file
#
open(INC, "/usr/X11R6/include/GL/gl.h") || die "Could not open GL/gl.h";
while ($line = <INC>) {
if ($line =~ /GLAPI.*GLAPIENTRY/) {
# Start of a function declaration
($ret, $name, $args) = ($line =~ /GLAPI (.*) GLAPIENTRY *(.*)\((.*)/);
# Remove all extensions except the multitexture one (see OpenGL ABI)
if (($name !~ /(MESA|PGI|ARB|EXT)/) ||
($name =~ /MultiTexCoord/) ||
($name =~ /ActiveTextureARB/)) {
print "/***********************************************************************\n";
print " *\t\t$name\n";
print " */\n";
print "$ret WINAPI wine_$name(";
@rargs = ();
@names = ();
# Now, get the parameters
while (1) {
@args = split /,|\)/, $args;
foreach (@args) {
if ($_ =~ /[a-z,A-Z]/) {
($a) = ($_ =~ /^\s*(.*)\s*$/);
if ($a =~ /\*\*/) {
($var) = ($a =~ /\*\*(\w*)/);
} elsif ($a =~ /\*/) {
($var) = ($a =~ /\*(\w*)/);
} else {
($var) = ($a =~ /\s(\w*)/);
}
@rargs = (@rargs, $a);
if ($var !~ /void/) {
@names = (@names, $var);
}
}
}
if ($args !~ /\)/) {
$args = <INC>;
} else {
last;
}
}
print shift @rargs;
foreach (@rargs) {
print ", $_";
}
print ") {\n";
if ($ret !~ /void/) {
print " $ret ret;\n";
}
print " ENTER_GL();\n";
if ($ret !~ /void/) {
print " ret = ";
} else {
print " ";
}
print "$name(";
$farg = shift @names;
if ($farg) {
print "$farg";
foreach (@names) {
print ", $_";
}
}
print ");\n";
print " LEAVE_GL();\n";
if ($ret !~ /void/) {
print " return ret;\n";
}
print "}\n\n";
}
}
}
close(INC);
#!/usr/bin/perl -w
#
# First, the basics and the wgl functions
#
print "
name opengl32
type win32
@ stdcall wglCreateContext(long) wglCreateContext
@ stdcall wglCreateLayerContext(long long) wglCreateLayerContext
@ stdcall wglCopyContext(long long long) wglCopyContext
@ stdcall wglDeleteContext(long) wglDeleteContext
@ stdcall wglDescribeLayerPlane(long long long long ptr) wglDescribeLayerPlane
@ stdcall wglGetCurrentContext() wglGetCurrentContext
@ stdcall wglGetCurrentDC() wglGetCurrentDC
@ stdcall wglGetLayerPaletteEntries(long long long long ptr) wglGetLayerPaletteEntries
@ stdcall wglGetProcAddress(str) wglGetProcAddress
@ stdcall wglMakeCurrent(long long) wglMakeCurrent
@ stdcall wglRealizeLayerPalette(long long long) wglRealizeLayerPalette
@ stdcall wglSetLayerPaletteEntries(long long long long ptr) wglSetLayerPaletteEntries
@ stdcall wglShareLists(long long) wglShareLists
@ stdcall wglSwapLayerBuffers(long long) wglSwapLayerBuffers
@ stdcall wglUseFontBitmapsA(long long long long) wglUseFontBitmapsA
@ stdcall wglUseFontOutlinesA(long long long long long long long ptr) wglUseFontOutlinesA
@ stub glGetLevelParameterfv
@ stub glGetLevelParameteriv
@ stub wglUseFontBitmapsW
@ stub wglUseFontOutlinesW
@ forward wglChoosePixelFormat GDI32.ChoosePixelFormat
@ forward wglDescribePixelFormat GDI32.DescribePixelFormat
@ forward wglGetPixelFormat GDI32.GetPixelFormat
@ forward wglSetPixelFormat GDI32.SetPixelFormat
@ forward wglSwapBuffers GDI32.SwapBuffers
";
#
# Now, the functions from the include file
#
open(INC, "/usr/X11R6/include/GL/gl.h") || die "Could not open GL/gl.h";
while ($line = <INC>) {
if ($line =~ /GLAPI.*GLAPIENTRY/) {
# Start of a function declaration
($name, $args) = ($line =~ /GLAPIENTRY *(.*)\((.*)/);
# Remove all extensions except the multitexture one (see OpenGL ABI)
if (($name !~ /(MESA|PGI|ARB|EXT)/) ||
($name =~ /MultiTexCoord/) ||
($name =~ /ActiveTextureARB/)) {
print "@ stdcall $name(";
# Now, get the parameters
while (1) {
@args = split /,/, $args;
foreach (@args) {
if ($_ =~ /\)/) {
($_) = ($_ =~ /(.*)\)/);
}
if ($_ =~ /\*/) {
print "ptr ";
} elsif ($_ =~ /[a-zA-Z]/) {
($type) = ($_ =~ /^ *(.*) +.*/);
if (($type =~ /double/) ||
($type =~ /clampd/)) {
print "double ";
} elsif ($type !~ /void/) {
print "long ";
}
}
}
if ($args !~ /\)/) {
$args = <INC>;
} else {
last;
}
}
print ") wine_$name\n";
}
}
}
close(INC);
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment