2000-06-12 03:21:18 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
# This script is called thus :
|
|
|
|
#
|
|
|
|
# make_opengl path_to_spec_file opengl_version
|
|
|
|
#
|
|
|
|
# - path_to_spec_file is the path to the directory where the OpenGL
|
|
|
|
# spec files are located. These files are part of the OpenGL
|
|
|
|
# sample implementation CVS tree and are located in
|
|
|
|
# CVS_ROOT/projects/ogl-sample/main/doc/registry/specs.
|
2001-03-04 02:05:20 +01:00
|
|
|
# You can find them on the web at the following URL :
|
|
|
|
# http://oss.sgi.com/cgi-bin/cvsweb.cgi/projects/ogl-sample/main/doc/registry/specs/
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# - opengl_version is the OpenGL version emulated by the library
|
|
|
|
# (can be 1.0 to 1.2).
|
|
|
|
#
|
|
|
|
# This script generates the three following files :
|
|
|
|
#
|
|
|
|
# - opengl32.spec : the spec file giving all the exported functions
|
|
|
|
# of the OpenGL32.DLL library. These functions are the one an
|
|
|
|
# application can directly link to (and are all the functions
|
|
|
|
# defined in the OpenGL core for the version defined by
|
|
|
|
# 'opengl_version').
|
|
|
|
#
|
|
|
|
# - opengl_norm.c : this file contains the thunks for all OpenGL
|
|
|
|
# functions that are defined in 'opengl32.spec'. The corresponding
|
|
|
|
# functions NEED to be defined in Linux's libGL or the library
|
|
|
|
# won't be able to be linked in.
|
|
|
|
#
|
|
|
|
# - opengl_ext.c : in this file are stored thunks for ALL possible
|
|
|
|
# OpenGL extensions (at least, all the extensions that are defined
|
|
|
|
# in the OpenGL extension registry). Contrary to 'opengl_norm.c',
|
|
|
|
# you do not need to have these extensions in your libGL to have
|
|
|
|
# OpenGL work (as they are resolved at run-time using
|
|
|
|
# glXGetProcAddressARB).
|
|
|
|
#
|
|
|
|
|
2001-03-04 02:05:20 +01:00
|
|
|
#
|
|
|
|
# Files to generate
|
|
|
|
#
|
|
|
|
$spec_file = "opengl32.spec";
|
|
|
|
$norm_file = "opengl_norm.c";
|
|
|
|
$ext_file = "opengl_ext.c";
|
|
|
|
|
|
|
|
# Set to 0 for removing the ENTER / LEAVE GL calls
|
|
|
|
$gen_thread_safe = 1;
|
|
|
|
# Prefix used for the local variables
|
|
|
|
$ext_prefix = "func_";
|
|
|
|
# If set to 1, generate TRACEs for each OpenGL function
|
|
|
|
$gen_traces = 1;
|
|
|
|
|
|
|
|
#
|
|
|
|
# List of categories to put in the 'opengl_norm.c' file
|
|
|
|
#
|
|
|
|
%cat_1_0 = ( "display-list" => 1,
|
|
|
|
"drawing" => 1,
|
|
|
|
"drawing-control" => 1,
|
|
|
|
"feedback" => 1,
|
|
|
|
"framebuf" => 1,
|
|
|
|
"misc" => 1,
|
|
|
|
"modeling" => 1,
|
|
|
|
"pixel-op" => 1,
|
|
|
|
"pixel-rw" => 1,
|
|
|
|
"state-req" => 1,
|
|
|
|
"xform" => 1 );
|
|
|
|
%cat_1_1 = ( %cat_1_0,
|
|
|
|
"1_1" => 1 );
|
|
|
|
%cat_1_2 = ( %cat_1_1,
|
|
|
|
"VERSION_1_2" => 1,
|
|
|
|
"ARB_multitexture" => 1 );
|
|
|
|
|
|
|
|
%norm_categories = ();
|
|
|
|
|
|
|
|
#
|
|
|
|
# This hash table gives the conversion between OpenGL types and what
|
|
|
|
# is used by the TRACE printfs
|
|
|
|
#
|
|
|
|
%debug_conv =
|
|
|
|
("GLbitfield" => "%d",
|
|
|
|
"GLboolean" => "%d",
|
|
|
|
"GLbyte" => "%d",
|
|
|
|
"GLclampd" => "%f",
|
|
|
|
"GLclampf" => "%f",
|
|
|
|
"GLdouble" => "%f",
|
|
|
|
"GLenum" => "%d",
|
|
|
|
"GLfloat" => "%f",
|
|
|
|
"GLint" => "%d",
|
|
|
|
"GLshort" => "%d",
|
|
|
|
"GLsizei" => "%d",
|
|
|
|
"GLstring" => "%s",
|
|
|
|
"GLubyte" => "%d",
|
|
|
|
"GLuint" => "%d",
|
|
|
|
"GLushort" => "%d",
|
|
|
|
"GLvoid" => "(void)",
|
|
|
|
"_GLfuncptr" => "%p");
|
|
|
|
|
|
|
|
#
|
|
|
|
# This hash table gives the conversion between OpenGL types and what
|
|
|
|
# is used in the .spec file
|
|
|
|
#
|
|
|
|
%arg_conv =
|
|
|
|
("GLbitfield" => [ "long", 4 ],
|
|
|
|
"GLboolean" => [ "long", 4 ],
|
|
|
|
"GLbyte" => [ "long", 4 ],
|
|
|
|
"GLclampd" => [ "double", 8 ],
|
|
|
|
"GLclampf" => [ "long", 4 ],
|
|
|
|
"GLdouble" => [ "double", 8 ],
|
|
|
|
"GLenum" => [ "long", 4 ],
|
|
|
|
"GLfloat" => [ "long", 4 ],
|
|
|
|
"GLint" => [ "long", 4 ],
|
|
|
|
"GLshort" => [ "long", 4 ],
|
|
|
|
"GLsizei" => [ "long", 4 ],
|
|
|
|
"GLstring" => [ "str", 4 ],
|
|
|
|
"GLubyte" => [ "long", 4 ],
|
|
|
|
"GLuint" => [ "long", 4 ],
|
|
|
|
"GLushort" => [ "long", 4 ],
|
|
|
|
"GLvoid" => [ "void", 4 ],
|
|
|
|
"_GLfuncptr" => [ "ptr", 4 ]);
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# This functions generates the thunk for a given function.
|
|
|
|
#
|
|
|
|
sub GenerateThunk {
|
|
|
|
my ($func_ref, $comment, $prefix, $thread_safe) = @_;
|
|
|
|
my ($ret) = ("");
|
|
|
|
my ($call_arg) = ("");
|
2001-03-04 02:05:20 +01:00
|
|
|
my ($trace_arg) = ("");
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
# If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
|
2001-07-31 02:08:05 +02:00
|
|
|
# Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($comment eq 1) {
|
|
|
|
$ret = $ret . "/***********************************************************************\n";
|
2001-07-31 02:08:05 +02:00
|
|
|
$ret = $ret . " * " . $func_ref->[0] . " (OPENGL32.@)\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
$ret = $ret . " */\n";
|
|
|
|
}
|
|
|
|
$ret = $ret . $func_ref->[1] . " WINAPI wine_" . $func_ref->[0] . "( ";
|
|
|
|
for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
|
|
|
|
$type = $func_ref->[2]->[$i]->[0];
|
|
|
|
$name = $func_ref->[2]->[$i]->[1];
|
|
|
|
$ret = $ret . "$type $name";
|
|
|
|
$call_arg = $call_arg . "$name";
|
2001-03-04 02:05:20 +01:00
|
|
|
if ($type =~ /\*/) {
|
|
|
|
$trace_arg = $trace_arg . "%p";
|
|
|
|
} else {
|
|
|
|
$trace_arg = $trace_arg . $debug_conv{$type};
|
|
|
|
}
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($i != $#{@{$func_ref->[2]}}) {
|
|
|
|
$ret = $ret . ", ";
|
|
|
|
$call_arg = $call_arg . ", ";
|
2001-03-04 02:05:20 +01:00
|
|
|
$trace_arg = $trace_arg . ", ";
|
2000-06-12 03:21:18 +02:00
|
|
|
} else {
|
|
|
|
$ret = $ret . " ";
|
|
|
|
$call_arg = $call_arg . " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$ret = $ret . ") {\n";
|
|
|
|
if ($func_ref->[1] ne "void") {
|
|
|
|
$ret = $ret . " " . $func_ref->[1] . " ret_value;\n";
|
|
|
|
}
|
2001-03-04 02:05:20 +01:00
|
|
|
if ($gen_traces) {
|
|
|
|
$ret = $ret . " TRACE(\"(" . $trace_arg . ")\\n\"";
|
|
|
|
if ($trace_arg ne "") {
|
|
|
|
$ret = $ret . ", " . $call_arg;
|
|
|
|
}
|
|
|
|
$ret = $ret . ");\n";
|
|
|
|
}
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($thread_safe) {
|
|
|
|
$ret = $ret . " ENTER_GL();\n";
|
|
|
|
}
|
|
|
|
$ret = $ret . " ";
|
|
|
|
if ($func_ref->[1] ne "void") {
|
|
|
|
$ret = $ret . "ret_value = ";
|
|
|
|
}
|
|
|
|
$ret = $ret . $prefix . $func_ref->[0] . "( " . $call_arg . ");\n";
|
|
|
|
if ($thread_safe) {
|
|
|
|
$ret = $ret . " LEAVE_GL();\n";
|
|
|
|
}
|
|
|
|
if ($func_ref->[1] ne "void") {
|
|
|
|
$ret = $ret . " return ret_value;\n"
|
|
|
|
}
|
|
|
|
$ret = $ret . "}\n";
|
|
|
|
|
|
|
|
# Return this string....
|
|
|
|
$ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Extract and checks the number of arguments
|
|
|
|
#
|
|
|
|
if ($#ARGV != 1) {
|
|
|
|
die "Usage : make_opengl OpenGL_registry_location OpenGL_version.\n";
|
|
|
|
}
|
|
|
|
$registry_path = shift @ARGV;
|
|
|
|
$version = shift @ARGV;
|
|
|
|
if ($version eq "1.0") {
|
|
|
|
%norm_categories = %cat_1_0;
|
|
|
|
} elsif ($version eq "1.1") {
|
|
|
|
%norm_categories = %cat_1_1;
|
|
|
|
} elsif ($version eq "1.2") {
|
|
|
|
%norm_categories = %cat_1_2;
|
|
|
|
} else {
|
|
|
|
die "OpenGL version incorrect. Should be one of '1.0', '1.1' or '1.2'.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Open the registry files
|
|
|
|
#
|
|
|
|
open(TYPES, $registry_path . "/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
|
|
|
|
open(REGISTRY, $registry_path . "/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
|
|
|
|
|
|
|
|
#
|
|
|
|
# First, create a mapping between the pseudo types used in the spec file
|
|
|
|
# and OpenGL types using the 'gl.tm' file.
|
|
|
|
#
|
|
|
|
%pseudo_to_opengl = ();
|
|
|
|
while ($line = <TYPES>) {
|
|
|
|
($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
|
|
|
|
$pseudo_to_opengl{$pseudo} = $opengl;
|
|
|
|
}
|
|
|
|
# This is to override the 'void' -> '*' bogus conversion
|
|
|
|
$pseudo_to_opengl{"void"} = "void";
|
2001-03-04 02:05:20 +01:00
|
|
|
# This is a bug in the spec file...
|
|
|
|
$pseudo_to_opengl{"FfdTargetSGIX"} = "GLint";
|
|
|
|
$pseudo_to_opengl{"FfdMaskSGIX"} = "GLint";
|
|
|
|
$pseudo_to_opengl{"IglooFunctionSelectSGIX"} = "GLint";
|
|
|
|
$pseudo_to_opengl{"IglooParameterSGIX"} = "GLint";
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Then, create the list of all OpenGL functions using the 'gl.spec'
|
|
|
|
# file. This will create two hash-tables, one with all the function
|
|
|
|
# whose category matches the one listed in '@norm_categories', the other
|
|
|
|
# with all other functions.
|
|
|
|
#
|
|
|
|
# An element of the hash table is a reference to an array with these
|
|
|
|
# elements :
|
|
|
|
#
|
|
|
|
# - function name
|
|
|
|
#
|
|
|
|
# - return type
|
|
|
|
#
|
|
|
|
# - reference to an array giving the list of arguments (an empty array
|
|
|
|
# for a 'void' function).
|
|
|
|
#
|
|
|
|
# The list of arguments is itself an array of reference to arrays. Each
|
|
|
|
# of these arrays represents the argument type and the argument name.
|
|
|
|
#
|
|
|
|
# An example :
|
|
|
|
#
|
|
|
|
# void glBitmap( GLsizei width, GLsizei height,
|
|
|
|
# GLfloat xorig, GLfloat yorig,
|
|
|
|
# GLfloat xmove, GLfloat ymove,
|
|
|
|
# const GLubyte *bitmap );
|
|
|
|
#
|
|
|
|
# Would give something like that :
|
|
|
|
#
|
|
|
|
# [ "glBitmap",
|
|
|
|
# "void",
|
|
|
|
# [ [ "GLsizei", "width" ],
|
|
|
|
# [ "GLsizei", "height" ],
|
|
|
|
# [ "GLfloat", "xorig" ],
|
|
|
|
# [ "GLfloat", "yorig" ],
|
|
|
|
# [ "GLfloat", "xmove" ],
|
|
|
|
# [ "GLfloat", "ymove" ],
|
|
|
|
# [ "GLubyte *", "bitmap"] ] ];
|
|
|
|
#
|
|
|
|
%norm_functions = ();
|
2001-07-31 02:08:05 +02:00
|
|
|
%ext_functions =
|
|
|
|
( "MultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s" ] ] ],
|
|
|
|
"MultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble *", "v" ] ] ],
|
|
|
|
"MultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ] ] ],
|
|
|
|
"MultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "const GLfloat *", "v" ] ] ],
|
|
|
|
"MultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ] ] ],
|
|
|
|
"MultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint *", "v" ] ] ],
|
|
|
|
"MultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ] ] ],
|
|
|
|
"MultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort *", "v" ] ] ],
|
|
|
|
"MultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s"],
|
|
|
|
[ "GLdouble", "t" ] ] ],
|
|
|
|
"MultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble *", "v" ] ] ],
|
|
|
|
"MultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ],
|
|
|
|
[ "GLfloat", "t" ] ] ],
|
|
|
|
"MultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat *", "v" ] ] ],
|
|
|
|
"MultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ],
|
|
|
|
[ "GLint", "t" ] ] ],
|
|
|
|
"MultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint *", "v" ] ] ],
|
|
|
|
"MultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ],
|
|
|
|
[ "GLshort", "t" ] ] ],
|
|
|
|
"MultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort *", "v" ] ] ],
|
|
|
|
"MultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s" ],
|
|
|
|
[ "GLdouble", "t" ],
|
|
|
|
[ "GLdouble", "r" ] ] ],
|
|
|
|
"MultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble *", "v" ] ] ],
|
|
|
|
"MultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ],
|
|
|
|
[ "GLfloat", "t" ],
|
|
|
|
[ "GLfloat", "r" ] ] ],
|
|
|
|
"MultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat *", "v" ] ] ],
|
|
|
|
"MultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ],
|
|
|
|
[ "GLint", "t" ],
|
|
|
|
[ "GLint", "r" ] ] ],
|
|
|
|
"MultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint *", "v" ] ] ],
|
|
|
|
"MultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ],
|
|
|
|
[ "GLshort", "t" ],
|
|
|
|
[ "GLshort", "r" ] ] ],
|
|
|
|
"MultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort *", "v" ] ] ],
|
|
|
|
"MultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s" ],
|
|
|
|
[ "GLdouble", "t" ],
|
|
|
|
[ "GLdouble", "r" ],
|
|
|
|
[ "GLdouble", "q" ] ] ],
|
|
|
|
"MultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble *", "v" ] ] ],
|
|
|
|
"MultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ],
|
|
|
|
[ "GLfloat", "t" ],
|
|
|
|
[ "GLfloat", "r" ],
|
|
|
|
[ "GLfloat", "q" ] ] ],
|
|
|
|
"MultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat *", "v" ] ] ],
|
|
|
|
"MultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ],
|
|
|
|
[ "GLint", "t" ],
|
|
|
|
[ "GLint", "r" ],
|
|
|
|
[ "GLint", "q" ] ] ],
|
|
|
|
"MultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint *", "v" ] ] ],
|
|
|
|
"MultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ],
|
|
|
|
[ "GLshort", "t" ],
|
|
|
|
[ "GLshort", "r" ],
|
|
|
|
[ "GLshort", "q" ] ] ],
|
|
|
|
"MultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort *", "v" ] ] ],
|
|
|
|
"MultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "size" ],
|
|
|
|
[ "GLenum", "type" ],
|
|
|
|
[ "GLsizei", "stride" ],
|
|
|
|
[ "GLvoid *", "pointer" ] ] ],
|
|
|
|
"SelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ] ],
|
|
|
|
"SelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ] ] );
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
while ($line = <REGISTRY>) {
|
|
|
|
if ($line =~ /^\w*\(.*\)/) {
|
|
|
|
# Get the function name (NOTE: the 'gl' prefix needs to be added later)
|
|
|
|
($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
|
|
|
|
# and the argument names
|
|
|
|
@arg_names = split /\s*,\s*/, $args;
|
|
|
|
|
|
|
|
# After get :
|
|
|
|
# - the return type
|
|
|
|
# - the argument types
|
|
|
|
# - the category the function belongs
|
|
|
|
%arg_types = ();
|
|
|
|
$category = "";
|
|
|
|
$ret_type = "";
|
|
|
|
while (1) {
|
|
|
|
$line = <REGISTRY>;
|
|
|
|
unless (defined($line)) {
|
|
|
|
last;
|
|
|
|
} elsif ($line =~ /^\s*$/) {
|
|
|
|
if (($category eq "") || ($ret_type eq "")) {
|
|
|
|
die "Missing 'category' line in function $funcname.\n";
|
|
|
|
}
|
|
|
|
last;
|
|
|
|
} elsif ($line =~ /\t*return\t*(\w*)/) {
|
|
|
|
($ret_type) = ($line =~ /\t*return\s*(\w*)/);
|
|
|
|
$ret_type = $pseudo_to_opengl{$ret_type};
|
|
|
|
unless (defined($ret_type)) {
|
|
|
|
die "Unsupported return type in function $funcname\n";
|
|
|
|
}
|
|
|
|
} elsif ($line =~ /^\t*category/) {
|
|
|
|
($category) = ($line =~ /^\t*category\s*([\w-]*)/);
|
|
|
|
} elsif ($line =~ /^\t*param/) {
|
|
|
|
($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
|
|
|
|
$ptr = 0;
|
|
|
|
unless (defined($name)) {
|
|
|
|
chomp $line;
|
|
|
|
die "Broken spec file line $line in function $funcname\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ext =~ /array/) {
|
|
|
|
# This is a pointer
|
|
|
|
$ptr = 1;
|
|
|
|
} elsif ($ext =~ /value/) {
|
|
|
|
# And this a 'normal' value
|
|
|
|
$ptr = 0;
|
|
|
|
} else {
|
|
|
|
chomp $line;
|
|
|
|
die "Unsupported type : $line in function $funcname\n";
|
|
|
|
}
|
|
|
|
# Get the 'real' type and append a '*' in case of a pointer
|
|
|
|
$type = $pseudo_to_opengl{$base_type};
|
|
|
|
unless (defined($type)) {
|
|
|
|
chomp $line;
|
|
|
|
die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
|
|
|
|
}
|
|
|
|
if ($ptr) {
|
|
|
|
$type = $type . "*";
|
|
|
|
}
|
|
|
|
|
|
|
|
$arg_types{$name} = $type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now, build the argument reference
|
|
|
|
$arg_ref = [ ];
|
|
|
|
for ($i = 0; $i <= $#arg_names; $i++) {
|
|
|
|
unless (defined($arg_types{$arg_names[$i]})) {
|
|
|
|
print "@arg_names\n";
|
|
|
|
foreach (sort keys %arg_types) {
|
|
|
|
print "$_ => $arg_types{$_}\n";
|
|
|
|
}
|
|
|
|
die "Undefined type for $arg_names[$i] in function $funcname\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
|
|
|
|
}
|
|
|
|
$func_ref = [ "gl" . $funcname,
|
|
|
|
$ret_type,
|
|
|
|
$arg_ref ];
|
|
|
|
|
|
|
|
# Now, put in one or the other hash table
|
|
|
|
if ($norm_categories{$category}) {
|
|
|
|
$norm_functions{$funcname} = $func_ref;
|
|
|
|
} else {
|
|
|
|
$ext_functions{$funcname} = $func_ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Clean up the input files
|
|
|
|
#
|
|
|
|
close(TYPES);
|
|
|
|
close(REGISTRY);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Now, generate the output files. First, the spec file.
|
|
|
|
#
|
|
|
|
open(SPEC, ">" . $spec_file);
|
|
|
|
|
2001-07-31 02:08:05 +02:00
|
|
|
print SPEC "name opengl32
|
2000-06-12 03:21:18 +02:00
|
|
|
type win32
|
2000-06-12 23:53:46 +02:00
|
|
|
init OpenGL32_Init
|
2001-07-31 02:08:05 +02:00
|
|
|
|
|
|
|
import user32.dll
|
|
|
|
import x11drv.dll
|
|
|
|
import kernel32.dll
|
|
|
|
import ntdll.dll
|
2001-03-04 02:05:20 +01:00
|
|
|
|
|
|
|
debug_channels (opengl)
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
@ 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
|
|
|
|
";
|
|
|
|
|
|
|
|
foreach (sort keys %norm_functions) {
|
|
|
|
$func_name = $norm_functions{$_}->[0];
|
|
|
|
print SPEC "@ stdcall $func_name( ";
|
|
|
|
for ($i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
|
|
|
|
$type = $norm_functions{$_}->[2]->[$i]->[0];
|
|
|
|
if ($type =~ /\*/) {
|
|
|
|
print SPEC "ptr ";
|
|
|
|
} elsif (defined($arg_conv{$type})) {
|
|
|
|
print SPEC "$@$arg_conv{$type}[0] ";
|
|
|
|
} else {
|
|
|
|
die "No convertion for GL type $type...\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print SPEC ") wine_$func_name\n";
|
|
|
|
}
|
|
|
|
close(SPEC);
|
|
|
|
|
|
|
|
#
|
|
|
|
# After the spec file, the opengl_norm.c file
|
|
|
|
#
|
|
|
|
open(NORM, ">" . $norm_file);
|
|
|
|
print NORM "
|
|
|
|
/* Auto-generated file... Do not edit ! */
|
|
|
|
|
|
|
|
#include \"config.h\"
|
|
|
|
#include \"wine_gl.h\"
|
2001-03-04 02:05:20 +01:00
|
|
|
#include \"debugtools.h\"
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
typedef const GLubyte * GLstring;
|
|
|
|
|
2001-03-04 02:05:20 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(opengl);
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
";
|
|
|
|
foreach (sort keys %norm_functions) {
|
|
|
|
$string = GenerateThunk($norm_functions{$_}, 1, "", $gen_thread_safe);
|
|
|
|
|
|
|
|
print NORM "$string\n";
|
|
|
|
}
|
|
|
|
close(NORM);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Finally, more complex, the opengl_ext.c file
|
|
|
|
#
|
|
|
|
open(EXT, ">" . $ext_file);
|
|
|
|
print EXT "
|
|
|
|
/* Auto-generated file... Do not edit ! */
|
|
|
|
|
|
|
|
#include \"config.h\"
|
|
|
|
#include \"wine_gl.h\"
|
2001-03-04 02:05:20 +01:00
|
|
|
#include \"debugtools.h\"
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
typedef const GLubyte * GLstring;
|
|
|
|
|
|
|
|
#include \"opengl_ext.h\"
|
|
|
|
|
2001-03-04 02:05:20 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(opengl);
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
";
|
|
|
|
|
|
|
|
# First, generate the function pointers
|
|
|
|
foreach (sort keys %ext_functions) {
|
|
|
|
$func_ref = $ext_functions{$_};
|
|
|
|
print EXT $func_ref->[1] . " (*" . $ext_prefix . $func_ref->[0] . ")( ";
|
|
|
|
for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
|
|
|
|
$type = $func_ref->[2]->[$i]->[0];
|
|
|
|
print EXT "$type";
|
|
|
|
if ($i != $#{@{$func_ref->[2]}}) {
|
|
|
|
print EXT ", ";
|
|
|
|
} else {
|
|
|
|
print EXT " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print EXT ") = (void *) 0xdeadbeef;\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Then, the function prototypes
|
|
|
|
print EXT "\n\n/* The function prototypes */\n";
|
|
|
|
foreach (sort keys %ext_functions) {
|
|
|
|
$func_ref = $ext_functions{$_};
|
|
|
|
print EXT $func_ref->[1] . " WINAPI " . "wine_" . $func_ref->[0] . "( ";
|
|
|
|
for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
|
|
|
|
$type = $func_ref->[2]->[$i]->[0];
|
|
|
|
print EXT "$type";
|
|
|
|
if ($i != $#{@{$func_ref->[2]}}) {
|
|
|
|
print EXT ", ";
|
|
|
|
} else {
|
|
|
|
print EXT " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print EXT ");\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Then the table giving the string <-> function correspondance */
|
|
|
|
print EXT "\n\n/* The table giving the correspondance between names and functions */\n";
|
|
|
|
@tmp = keys %ext_functions;
|
|
|
|
print EXT "int extension_registry_size = " . ($#tmp + 1) . ";\n";
|
|
|
|
print EXT "OpenGL_extension extension_registry[" . ($#tmp + 1) . "] = {\n";
|
|
|
|
$i = 0;
|
|
|
|
foreach (sort keys %ext_functions) {
|
|
|
|
$func_ref = $ext_functions{$_};
|
|
|
|
print EXT " { \"" . $func_ref->[0] . "\", (void *) wine_" . $func_ref->[0] . ", (void **) (&" . $ext_prefix . $func_ref->[0] . ") }";
|
|
|
|
if ($i != $#tmp) {
|
|
|
|
print EXT ",";
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
print EXT "\n";
|
|
|
|
}
|
|
|
|
print EXT "};\n";
|
|
|
|
|
|
|
|
# And, finally, the thunks themselves....
|
|
|
|
print EXT "\n/* The thunks themselves....*/\n";
|
|
|
|
foreach (sort keys %ext_functions) {
|
|
|
|
$string = GenerateThunk($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe);
|
|
|
|
|
|
|
|
print EXT "$string\n";
|
|
|
|
}
|
|
|
|
close(EXT);
|