2000-06-12 03:21:18 +02:00
|
|
|
#!/usr/bin/perl -w
|
2005-05-20 20:58:10 +02:00
|
|
|
use strict;
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
# This script is called thus :
|
|
|
|
#
|
2009-01-08 12:29:39 +01:00
|
|
|
# make_opengl [opengl_version]
|
|
|
|
#
|
|
|
|
# - It needs the gl.spec and gl.tm files in the current directory.
|
|
|
|
# These files are hosted in the OpenGL extension registry at
|
|
|
|
# opengl.org:
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
2007-08-17 19:22:12 +02:00
|
|
|
# http://www.opengl.org/registry/api/gl.spec
|
|
|
|
# http://www.opengl.org/registry/api/gl.tm
|
|
|
|
#
|
2009-01-08 12:29:39 +01:00
|
|
|
# If they are not found in the current directory the script will
|
|
|
|
# attempt to download them from there.
|
|
|
|
#
|
2007-08-17 19:22:12 +02:00
|
|
|
# The files used to be hosted and maintained by SGI. You can still find
|
|
|
|
# find them in the sample implementation CVS tree which is located at
|
2000-06-12 03:21:18 +02:00
|
|
|
# CVS_ROOT/projects/ogl-sample/main/doc/registry/specs.
|
2007-08-17 19:22:12 +02:00
|
|
|
# You can also find them on the web at the following URL :
|
2001-03-04 02:05:20 +01:00
|
|
|
# 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
|
2009-06-11 11:53:40 +02:00
|
|
|
# (can be 1.0 to 1.5). The default is 1.1.
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# 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).
|
|
|
|
#
|
2002-03-10 00:29:33 +01:00
|
|
|
# Copyright 2000 Lionel Ulmer
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
2000-06-12 03:21:18 +02:00
|
|
|
|
2001-03-04 02:05:20 +01:00
|
|
|
#
|
|
|
|
# Files to generate
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
my $spec_file = "opengl32.spec";
|
|
|
|
my $norm_file = "opengl_norm.c";
|
|
|
|
my $ext_file = "opengl_ext.c";
|
2001-03-04 02:05:20 +01:00
|
|
|
|
|
|
|
# Set to 0 for removing the ENTER / LEAVE GL calls
|
2005-05-20 20:58:10 +02:00
|
|
|
my $gen_thread_safe = 1;
|
2001-03-04 02:05:20 +01:00
|
|
|
# Prefix used for the local variables
|
2005-05-20 20:58:10 +02:00
|
|
|
my $ext_prefix = "func_";
|
2001-03-04 02:05:20 +01:00
|
|
|
# If set to 1, generate TRACEs for each OpenGL function
|
2005-05-20 20:58:10 +02:00
|
|
|
my $gen_traces = 1;
|
2001-03-04 02:05:20 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# List of categories to put in the 'opengl_norm.c' file
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
my %cat_1_0 = ( "display-list" => 1,
|
2002-06-01 04:55:48 +02:00
|
|
|
"drawing" => 1,
|
|
|
|
"drawing-control" => 1,
|
|
|
|
"feedback" => 1,
|
|
|
|
"framebuf" => 1,
|
|
|
|
"misc" => 1,
|
|
|
|
"modeling" => 1,
|
|
|
|
"pixel-op" => 1,
|
|
|
|
"pixel-rw" => 1,
|
|
|
|
"state-req" => 1,
|
2009-05-28 15:23:10 +02:00
|
|
|
"xform" => 1,
|
|
|
|
"VERSION_1_0" => 1,
|
|
|
|
"VERSION_1_0_DEPRECATED" => 1 );
|
2005-05-20 20:58:10 +02:00
|
|
|
my %cat_1_1 = ( %cat_1_0,
|
2009-05-28 15:23:10 +02:00
|
|
|
"VERSION_1_1" => 1,
|
|
|
|
"VERSION_1_1_DEPRECATED" => 1 );
|
2005-05-20 20:58:10 +02:00
|
|
|
my %cat_1_2 = ( %cat_1_1,
|
2009-05-28 15:23:10 +02:00
|
|
|
"VERSION_1_2" => 1,
|
|
|
|
"VERSION_1_2_DEPRECATED" => 1 );
|
2005-05-20 20:58:10 +02:00
|
|
|
my %cat_1_3 = ( %cat_1_2,
|
2009-05-28 15:23:10 +02:00
|
|
|
"VERSION_1_3" => 1,
|
|
|
|
"VERSION_1_3_DEPRECATED" => 1 );
|
2005-05-20 20:58:10 +02:00
|
|
|
my %cat_1_4 = ( %cat_1_3,
|
2009-05-28 15:23:10 +02:00
|
|
|
"VERSION_1_4" => 1,
|
|
|
|
"VERSION_1_4_DEPRECATED" => 1 );
|
2005-05-20 20:58:10 +02:00
|
|
|
my %cat_1_5 = ( %cat_1_4,
|
2009-05-28 15:23:10 +02:00
|
|
|
"VERSION_1_5" => 1,
|
|
|
|
"VERSION_1_5_DEPRECATED" => 1 );
|
2001-03-04 02:05:20 +01:00
|
|
|
|
2005-05-20 20:58:10 +02:00
|
|
|
my %norm_categories = ();
|
2001-03-04 02:05:20 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# This hash table gives the conversion between OpenGL types and what
|
|
|
|
# is used by the TRACE printfs
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
my %debug_conv =
|
2001-03-04 02:05:20 +01:00
|
|
|
("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",
|
2003-06-13 18:31:17 +02:00
|
|
|
"GLhalfNV" => "%d",
|
2009-01-08 12:15:47 +01:00
|
|
|
"GLintptrARB" => "%ld",
|
|
|
|
"GLsizeiptrARB" => "%ld",
|
|
|
|
"GLintptr" => "%ld",
|
|
|
|
"GLsizeiptr" => "%ld",
|
2004-03-02 21:54:17 +01:00
|
|
|
"GLhandleARB" => "%d",
|
|
|
|
"GLcharARB" => "%c",
|
2001-03-04 02:05:20 +01:00
|
|
|
"GLvoid" => "(void)",
|
2009-05-28 15:23:10 +02:00
|
|
|
"_GLfuncptr" => "%p",
|
2010-08-31 22:19:54 +02:00
|
|
|
"GLDEBUGPROCARB" => "%p",
|
|
|
|
"GLDEBUGPROCAMD" => "%p",
|
|
|
|
"GLvdpauSurfaceNV" => "%ld",
|
|
|
|
"INT64" => "%s,wine_dbgstr_longlong(%s)",
|
2009-05-28 15:23:10 +02:00
|
|
|
"UINT64" => "%s,wine_dbgstr_longlong(%s)"
|
|
|
|
);
|
2001-03-04 02:05:20 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# This hash table gives the conversion between OpenGL types and what
|
|
|
|
# is used in the .spec file
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
my %arg_conv =
|
2001-03-04 02:05:20 +01:00
|
|
|
("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 ],
|
2003-06-13 18:31:17 +02:00
|
|
|
"GLhalfNV" => [ "long", 4 ],
|
|
|
|
"GLintptrARB" => [ "long", 4 ],
|
|
|
|
"GLsizeiptrARB" => [ "long", 4 ],
|
2004-03-02 21:54:17 +01:00
|
|
|
"GLhandleARB" => [ "long", 4 ],
|
|
|
|
"GLcharARB" => [ "long", 4 ],
|
|
|
|
"GLintptr" => [ "long", 4 ],
|
|
|
|
"GLsizeiptr" => [ "long", 4 ],
|
2001-03-04 02:05:20 +01:00
|
|
|
"GLvoid" => [ "void", 4 ],
|
|
|
|
"_GLfuncptr" => [ "ptr", 4 ]);
|
|
|
|
|
2003-06-20 23:29:28 +02:00
|
|
|
#
|
|
|
|
# Used to convert some types
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
sub ConvertType($)
|
|
|
|
{
|
2003-06-20 23:29:28 +02:00
|
|
|
my ($type) = @_;
|
|
|
|
|
2005-05-20 20:58:10 +02:00
|
|
|
my %hash = ( "GLstring" => "const GLubyte *",
|
2009-01-08 12:15:47 +01:00
|
|
|
"GLintptrARB" => "INT_PTR",
|
|
|
|
"GLsizeiptrARB" => "INT_PTR",
|
|
|
|
"GLintptr" => "INT_PTR",
|
|
|
|
"GLsizeiptr" => "INT_PTR",
|
2004-03-02 21:54:17 +01:00
|
|
|
"GLhandleARB" => "unsigned int",
|
|
|
|
"GLcharARB" => "char",
|
2006-06-09 16:26:44 +02:00
|
|
|
"GLchar" => "char",
|
2010-08-31 22:19:54 +02:00
|
|
|
"GLhalfNV" => "unsigned short",
|
|
|
|
"GLvdpauSurfaceNV" => "INT_PTR",
|
|
|
|
"struct _cl_context" => "void",
|
|
|
|
"struct _cl_event" => "void",
|
|
|
|
"GLDEBUGPROCARB" => "void *",
|
|
|
|
"GLDEBUGPROCAMD" => "void *" );
|
2003-06-20 23:29:28 +02:00
|
|
|
|
2005-05-20 20:58:10 +02:00
|
|
|
foreach my $org (reverse sort keys %hash) {
|
2003-06-20 23:29:28 +02:00
|
|
|
if ($type =~ /$org/) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
|
2003-06-20 23:29:28 +02:00
|
|
|
return "$before$hash{$org}$after";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
}
|
|
|
|
|
2004-03-02 21:54:17 +01:00
|
|
|
#
|
|
|
|
# Used to convert some variable names
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
sub ConvertVarName($)
|
|
|
|
{
|
2004-03-02 21:54:17 +01:00
|
|
|
my ($type) = @_;
|
|
|
|
|
2005-05-20 20:58:10 +02:00
|
|
|
my %hash = ( "near" => "nearParam",
|
|
|
|
"far" => "farParam" );
|
2004-03-02 21:54:17 +01:00
|
|
|
|
2005-05-20 20:58:10 +02:00
|
|
|
foreach my $org (keys %hash) {
|
2004-03-02 21:54:17 +01:00
|
|
|
if ($type =~ /$org/) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
|
2004-03-02 21:54:17 +01:00
|
|
|
return "$before$hash{$org}$after";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
}
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# This functions generates the thunk for a given function.
|
|
|
|
#
|
2006-06-09 18:13:09 +02:00
|
|
|
sub GenerateThunk($$$$$)
|
2005-05-20 20:58:10 +02:00
|
|
|
{
|
2006-06-09 18:13:09 +02:00
|
|
|
my ($func_ref, $comment, $prefix, $thread_safe, $local_var) = @_;
|
2005-05-20 20:58:10 +02:00
|
|
|
my $ret = "";
|
|
|
|
my $call_arg = "";
|
2009-05-28 15:23:10 +02:00
|
|
|
my $trace_call_arg = "";
|
2005-05-20 20:58:10 +02:00
|
|
|
my $trace_arg = "";
|
2006-12-12 17:59:44 +01:00
|
|
|
|
|
|
|
return "" if $func_ref->[0] eq "glGetString";
|
|
|
|
return "" if $func_ref->[0] eq "glGetIntegerv";
|
2007-09-23 05:45:27 +02:00
|
|
|
return "" if $func_ref->[0] eq "glFinish";
|
|
|
|
return "" if $func_ref->[0] eq "glFlush";
|
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) {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret/***********************************************************************\n";
|
|
|
|
$ret = "$ret * $func_ref->[0] (OPENGL32.\@)\n";
|
|
|
|
$ret = "$ret */\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = $ret . ConvertType($func_ref->[1]) . " WINAPI wine_$func_ref->[0]( ";
|
2008-09-25 16:48:03 +02:00
|
|
|
for (my $i = 0; $i < @{$func_ref->[2]}; $i++) {
|
2004-03-02 21:54:17 +01:00
|
|
|
## Quick debug code :-)
|
|
|
|
## print $func_ref->[2]->[$i]->[1] . "\n";
|
2005-05-20 20:58:10 +02:00
|
|
|
my $type = $func_ref->[2]->[$i]->[0];
|
|
|
|
my $name = ConvertVarName($func_ref->[2]->[$i]->[1]);
|
2009-05-28 15:23:10 +02:00
|
|
|
$ret .= ConvertType($type) . " $name";
|
|
|
|
$call_arg .= $name;
|
2001-03-04 02:05:20 +01:00
|
|
|
if ($type =~ /\*/) {
|
2009-05-28 15:23:10 +02:00
|
|
|
$trace_arg .= "%p";
|
|
|
|
$trace_call_arg .= $name;
|
2010-08-31 22:19:54 +02:00
|
|
|
} elsif (defined $debug_conv{$type}) {
|
2009-05-28 15:23:10 +02:00
|
|
|
if ($debug_conv{$type} =~ /(.*),(.*)/)
|
|
|
|
{
|
|
|
|
$trace_arg .= $1;
|
|
|
|
$trace_call_arg .= sprintf $2, $name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$trace_arg .= $debug_conv{$type};
|
|
|
|
$trace_call_arg .= $name;
|
|
|
|
}
|
2001-03-04 02:05:20 +01:00
|
|
|
}
|
2010-08-31 22:19:54 +02:00
|
|
|
else { printf "Unknown type %s\n", $type; }
|
2008-09-25 16:48:03 +02:00
|
|
|
if ($i+1 < @{$func_ref->[2]}) {
|
2009-05-28 15:23:10 +02:00
|
|
|
$ret .= ", ";
|
|
|
|
$call_arg .= ", ";
|
|
|
|
$trace_call_arg .= ", ";
|
|
|
|
$trace_arg .= ", ";
|
2000-06-12 03:21:18 +02:00
|
|
|
} else {
|
2009-05-28 15:23:10 +02:00
|
|
|
$ret .= " ";
|
|
|
|
$call_arg .= " ";
|
|
|
|
$trace_call_arg .= " ";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
2008-09-25 16:48:03 +02:00
|
|
|
$ret .= 'void ' if (!@{$func_ref->[2]});
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret) {\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($func_ref->[1] ne "void") {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret " . ConvertType($func_ref->[1]) . " ret_value;\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2006-06-09 18:13:09 +02:00
|
|
|
$ret .= $local_var;
|
2001-03-04 02:05:20 +01:00
|
|
|
if ($gen_traces) {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret TRACE(\"($trace_arg)\\n\"";
|
2001-03-04 02:05:20 +01:00
|
|
|
if ($trace_arg ne "") {
|
2009-05-28 15:23:10 +02:00
|
|
|
$ret .= ", $trace_call_arg";
|
2001-03-04 02:05:20 +01:00
|
|
|
}
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret);\n";
|
2001-03-04 02:05:20 +01:00
|
|
|
}
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($thread_safe) {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret ENTER_GL();\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret ";
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($func_ref->[1] ne "void") {
|
|
|
|
$ret = $ret . "ret_value = ";
|
|
|
|
}
|
2006-12-12 17:59:44 +01:00
|
|
|
$ret = "$ret$prefix$func_ref->[0]( $call_arg);\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($thread_safe) {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret LEAVE_GL();\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
if ($func_ref->[1] ne "void") {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret return ret_value;\n"
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2005-05-20 20:58:10 +02:00
|
|
|
$ret = "$ret}\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
# Return this string....
|
2005-05-20 20:58:10 +02:00
|
|
|
return $ret;
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Extract and checks the number of arguments
|
|
|
|
#
|
2009-01-08 12:29:39 +01:00
|
|
|
if (@ARGV > 1) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my $name0=$0;
|
|
|
|
$name0=~s%^.*/%%;
|
2009-01-08 12:29:39 +01:00
|
|
|
die "Usage: $name0 [version]\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2009-06-11 11:53:40 +02:00
|
|
|
my $version = $ARGV[0] || "1.1";
|
2000-06-12 03:21:18 +02:00
|
|
|
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;
|
2004-03-02 21:54:17 +01:00
|
|
|
} elsif ($version eq "1.3") {
|
|
|
|
%norm_categories = %cat_1_3;
|
|
|
|
} elsif ($version eq "1.4") {
|
|
|
|
%norm_categories = %cat_1_4;
|
|
|
|
} elsif ($version eq "1.5") {
|
|
|
|
%norm_categories = %cat_1_5;
|
2000-06-12 03:21:18 +02:00
|
|
|
} else {
|
2004-03-02 21:54:17 +01:00
|
|
|
die "Incorrect OpenGL version.\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
2009-01-08 12:29:39 +01:00
|
|
|
#
|
|
|
|
# Fetch the registry files
|
|
|
|
#
|
|
|
|
-f "gl.spec" || system "wget http://www.opengl.org/registry/api/gl.spec" || die "cannot download gl.spec";
|
|
|
|
-f "gl.tm" || system "wget http://www.opengl.org/registry/api/gl.tm" || die "cannot download gl.tm";
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# Open the registry files
|
|
|
|
#
|
2009-01-08 12:29:39 +01:00
|
|
|
open(TYPES, "gl.tm") || die "Could not open gl.tm";
|
|
|
|
open(REGISTRY, "gl.spec") || die "Could not open gl.spec";
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# First, create a mapping between the pseudo types used in the spec file
|
|
|
|
# and OpenGL types using the 'gl.tm' file.
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
my %pseudo_to_opengl = ();
|
|
|
|
while (my $line = <TYPES>) {
|
2003-06-13 18:31:17 +02:00
|
|
|
if ($line !~ /\w*\#/) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
|
2003-06-13 18:31:17 +02:00
|
|
|
$pseudo_to_opengl{$pseudo} = $opengl;
|
|
|
|
}
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
# This is to override the 'void' -> '*' bogus conversion
|
|
|
|
$pseudo_to_opengl{"void"} = "void";
|
2009-08-04 23:42:41 +02:00
|
|
|
$pseudo_to_opengl{"sync"} = "GLvoid*";
|
|
|
|
$pseudo_to_opengl{"Int64"} = "INT64";
|
|
|
|
$pseudo_to_opengl{"UInt64"} = "UINT64";
|
2007-08-20 18:04:40 +02:00
|
|
|
$pseudo_to_opengl{"Int64EXT"} = "INT64";
|
|
|
|
$pseudo_to_opengl{"UInt64EXT"} = "UINT64";
|
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"] ] ];
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
my %norm_functions = ();
|
2003-03-04 03:17:04 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# This stores various extensions NOT part of the GL extension registry but still
|
|
|
|
# implemented by most OpenGL libraries out there...
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
|
|
|
|
my %ext_functions =
|
2006-10-29 22:56:27 +01:00
|
|
|
( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion", "GL_KTX_buffer_region" ],
|
2003-03-04 03:17:04 +01:00
|
|
|
"glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
|
|
|
|
[ "GLint", "x" ],
|
|
|
|
[ "GLint", "y" ],
|
|
|
|
[ "GLsizei", "width" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLsizei", "height" ] ], "glReadBufferRegion", "GL_KTX_buffer_region" ],
|
2003-03-04 03:17:04 +01:00
|
|
|
"glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
|
|
|
|
[ "GLint", "x" ],
|
|
|
|
[ "GLint", "y" ],
|
|
|
|
[ "GLsizei", "width" ],
|
|
|
|
[ "GLsizei", "height" ],
|
|
|
|
[ "GLint", "xDest" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint", "yDest" ] ], "glDrawBufferRegion", "GL_KTX_buffer_region" ],
|
|
|
|
"glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled", "GL_KTX_buffer_region" ],
|
|
|
|
"glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion", "GL_KTX_buffer_region" ],
|
2003-03-04 03:17:04 +01:00
|
|
|
"glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
|
2002-03-20 01:58:40 +01:00
|
|
|
[ "GLfloat", "s" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat", "t" ] ], "glMTexCoord2fSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint", "s" ] ], "glMultiTexCoord1iSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s"],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint", "t" ] ], "glMultiTexCoord2iSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s" ],
|
|
|
|
[ "GLdouble", "t" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS", "GL_SGIS_multitexture" ],
|
2002-01-02 22:43:19 +01:00
|
|
|
"glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ],
|
|
|
|
[ "GLfloat", "t" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ],
|
|
|
|
[ "GLint", "t" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint", "r" ] ], "glMultiTexCoord3iSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ],
|
|
|
|
[ "GLshort", "t" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLdouble", "s" ],
|
|
|
|
[ "GLdouble", "t" ],
|
|
|
|
[ "GLdouble", "r" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLfloat", "s" ],
|
|
|
|
[ "GLfloat", "t" ],
|
|
|
|
[ "GLfloat", "r" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "s" ],
|
|
|
|
[ "GLint", "t" ],
|
|
|
|
[ "GLint", "r" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint", "q" ] ], "glMultiTexCoord4iSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLshort", "s" ],
|
|
|
|
[ "GLshort", "t" ],
|
|
|
|
[ "GLshort", "r" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS", "GL_SGIS_multitexture" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
"glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
|
|
|
|
[ "GLint", "size" ],
|
2002-01-02 22:43:19 +01:00
|
|
|
[ "GLenum", "type" ],
|
2002-06-01 04:55:48 +02:00
|
|
|
[ "GLsizei", "stride" ],
|
2006-10-29 22:56:27 +01:00
|
|
|
[ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS", "GL_SGIS_multitexture" ],
|
|
|
|
"glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS", "GL_SGIS_multitexture" ],
|
|
|
|
"glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS", "GL_SGIS_multitexture" ],
|
|
|
|
"glDeleteObjectBufferATI" => [ "glDeleteObjectBufferATI", "void", [ [ "GLuint", "buffer" ] ], "glDeleteObjectBufferATI", "GL_ATI_vertex_array_object" ]
|
2002-01-02 22:43:19 +01:00
|
|
|
);
|
2001-07-31 02:08:05 +02:00
|
|
|
|
2005-05-20 20:58:10 +02:00
|
|
|
my @arg_names;
|
|
|
|
my %arg_types;
|
|
|
|
while (my $line = <REGISTRY>) {
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($line =~ /^\w*\(.*\)/) {
|
|
|
|
# Get the function name (NOTE: the 'gl' prefix needs to be added later)
|
2005-05-20 20:58:10 +02:00
|
|
|
my ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
|
2000-06-12 03:21:18 +02:00
|
|
|
# and the argument names
|
|
|
|
@arg_names = split /\s*,\s*/, $args;
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
# After get :
|
|
|
|
# - the return type
|
2006-10-29 22:56:27 +01:00
|
|
|
# - category (the extension the function is part of)
|
2000-06-12 03:21:18 +02:00
|
|
|
# - the argument types
|
|
|
|
# - the category the function belongs
|
|
|
|
%arg_types = ();
|
2005-05-20 20:58:10 +02:00
|
|
|
my $category = "";
|
|
|
|
my $ret_type = "";
|
2000-06-12 03:21:18 +02:00
|
|
|
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/) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my ($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
|
|
|
|
my $ptr = 0;
|
2002-06-01 04:55:48 +02:00
|
|
|
unless (defined($name)) {
|
2000-06-12 03:21:18 +02:00
|
|
|
chomp $line;
|
|
|
|
die "Broken spec file line $line in function $funcname\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ext =~ /array/) {
|
|
|
|
# This is a pointer
|
|
|
|
$ptr = 1;
|
2009-11-18 12:58:41 +01:00
|
|
|
} elsif ($ext =~ /reference/) {
|
|
|
|
# This is a pointer
|
|
|
|
$ptr = 1;
|
2000-06-12 03:21:18 +02:00
|
|
|
} 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
|
2005-05-20 20:58:10 +02:00
|
|
|
my $type = $pseudo_to_opengl{$base_type};
|
2000-06-12 03:21:18 +02:00
|
|
|
unless (defined($type)) {
|
|
|
|
chomp $line;
|
|
|
|
die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
|
|
|
|
}
|
|
|
|
if ($ptr) {
|
2005-05-20 20:58:10 +02:00
|
|
|
$type = "$type*";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
$arg_types{$name} = $type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now, build the argument reference
|
2005-05-20 20:58:10 +02:00
|
|
|
my $arg_ref = [ ];
|
2008-09-25 16:48:03 +02:00
|
|
|
for (my $i = 0; $i < @arg_names; $i++) {
|
2000-06-12 03:21:18 +02:00
|
|
|
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";
|
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
push @$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
|
|
|
|
}
|
2005-05-20 20:58:10 +02:00
|
|
|
my $func_ref = [ "gl$funcname",
|
|
|
|
$ret_type,
|
|
|
|
$arg_ref,
|
2006-10-29 22:56:27 +01:00
|
|
|
"gl$funcname",
|
|
|
|
"GL_$category" ];
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
# Now, put in one or the other hash table
|
|
|
|
if ($norm_categories{$category}) {
|
2005-05-20 20:58:10 +02:00
|
|
|
$norm_functions{"gl$funcname"} = $func_ref;
|
2000-06-12 03:21:18 +02:00
|
|
|
} else {
|
2005-05-20 20:58:10 +02:00
|
|
|
$ext_functions{"gl$funcname"} = $func_ref;
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Clean up the input files
|
|
|
|
#
|
|
|
|
close(TYPES);
|
|
|
|
close(REGISTRY);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Now, generate the output files. First, the spec file.
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
open(SPEC, ">$spec_file");
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
foreach (sort keys %norm_functions) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my $func_name = $norm_functions{$_}->[0];
|
2000-06-12 03:21:18 +02:00
|
|
|
print SPEC "@ stdcall $func_name( ";
|
2008-09-25 16:48:03 +02:00
|
|
|
for (my $i = 0; $i < @{$norm_functions{$_}->[2]}; $i++) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my $type = $norm_functions{$_}->[2]->[$i]->[0];
|
2000-06-12 03:21:18 +02:00
|
|
|
if ($type =~ /\*/) {
|
|
|
|
print SPEC "ptr ";
|
|
|
|
} elsif (defined($arg_conv{$type})) {
|
|
|
|
print SPEC "$@$arg_conv{$type}[0] ";
|
|
|
|
} else {
|
2005-05-30 11:56:56 +02:00
|
|
|
die "No conversion for GL type $type...\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print SPEC ") wine_$func_name\n";
|
|
|
|
}
|
2006-12-12 17:59:44 +01:00
|
|
|
|
2009-06-11 11:53:40 +02:00
|
|
|
print SPEC "@ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
|
2007-11-11 21:32:12 +01:00
|
|
|
@ stdcall wglCopyContext(long long long) gdi32.wglCopyContext
|
2006-12-12 17:59:44 +01:00
|
|
|
@ stdcall wglCreateContext(long) gdi32.wglCreateContext
|
|
|
|
@ stdcall wglCreateLayerContext(long long)
|
|
|
|
@ stdcall wglDeleteContext(long) gdi32.wglDeleteContext
|
|
|
|
@ stdcall wglDescribeLayerPlane(long long long long ptr)
|
|
|
|
@ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
|
|
|
|
@ stdcall wglGetCurrentContext() gdi32.wglGetCurrentContext
|
|
|
|
@ stdcall wglGetCurrentDC() gdi32.wglGetCurrentDC
|
|
|
|
@ stub wglGetDefaultProcAddress
|
|
|
|
@ stdcall wglGetLayerPaletteEntries(long long long long ptr)
|
|
|
|
@ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
|
|
|
|
@ stdcall wglGetProcAddress(str)
|
|
|
|
@ stdcall wglMakeCurrent(long long) gdi32.wglMakeCurrent
|
|
|
|
@ stdcall wglRealizeLayerPalette(long long long)
|
|
|
|
@ stdcall wglSetLayerPaletteEntries(long long long long ptr)
|
|
|
|
@ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
|
|
|
|
@ stdcall wglShareLists(long long) gdi32.wglShareLists
|
2009-10-14 23:20:20 +02:00
|
|
|
@ stdcall wglSwapBuffers(long)
|
2006-12-12 17:59:44 +01:00
|
|
|
@ stdcall wglSwapLayerBuffers(long long)
|
|
|
|
@ stdcall wglUseFontBitmapsA(long long long long) gdi32.wglUseFontBitmapsA
|
|
|
|
@ stdcall wglUseFontBitmapsW(long long long long) gdi32.wglUseFontBitmapsW
|
|
|
|
@ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
|
|
|
|
@ stdcall wglUseFontOutlinesW(long long long long long long long ptr)
|
|
|
|
";
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
close(SPEC);
|
|
|
|
|
|
|
|
#
|
|
|
|
# After the spec file, the opengl_norm.c file
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
open(NORM, ">$norm_file");
|
2000-06-12 03:21:18 +02:00
|
|
|
print NORM "
|
|
|
|
/* Auto-generated file... Do not edit ! */
|
|
|
|
|
|
|
|
#include \"config.h\"
|
2002-09-25 02:29:56 +02:00
|
|
|
#include \"opengl_ext.h\"
|
2002-03-20 01:58:40 +01:00
|
|
|
#include \"wine/debug.h\"
|
2000-06-12 03:21:18 +02:00
|
|
|
|
2002-03-20 01:58:40 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
|
2000-06-12 03:21:18 +02:00
|
|
|
";
|
|
|
|
foreach (sort keys %norm_functions) {
|
2006-06-09 18:13:09 +02:00
|
|
|
my $string = GenerateThunk($norm_functions{$_}, 1, "", $gen_thread_safe, "");
|
2000-06-12 03:21:18 +02:00
|
|
|
|
2006-12-12 17:59:44 +01:00
|
|
|
print NORM "\n$string" if $string;
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
close(NORM);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Finally, more complex, the opengl_ext.c file
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
open(EXT, ">$ext_file");
|
2000-06-12 03:21:18 +02:00
|
|
|
print EXT "
|
|
|
|
/* Auto-generated file... Do not edit ! */
|
|
|
|
|
|
|
|
#include \"config.h\"
|
2002-09-25 02:29:56 +02:00
|
|
|
#include \"opengl_ext.h\"
|
2002-03-20 01:58:40 +01:00
|
|
|
#include \"wine/debug.h\"
|
2000-06-12 03:21:18 +02:00
|
|
|
|
2002-03-20 01:58:40 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
|
2001-03-04 02:05:20 +01:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
";
|
|
|
|
|
2006-06-09 18:13:09 +02:00
|
|
|
# The thunks themselves....
|
|
|
|
my $count = keys %ext_functions;
|
2008-12-30 12:20:47 +01:00
|
|
|
print EXT "enum extensions\n{\n";
|
|
|
|
foreach (sort keys %ext_functions) {
|
|
|
|
my $func_ref = $ext_functions{$_};
|
|
|
|
print EXT " EXT_$func_ref->[0],\n";
|
|
|
|
}
|
|
|
|
print EXT " NB_EXTENSIONS\n};\n\n";
|
|
|
|
print EXT "const int extension_registry_size = NB_EXTENSIONS;\n";
|
|
|
|
print EXT "void *extension_funcs[NB_EXTENSIONS];\n";
|
2006-06-09 18:13:09 +02:00
|
|
|
print EXT "\n/* The thunks themselves....*/";
|
2000-06-12 03:21:18 +02:00
|
|
|
foreach (sort keys %ext_functions) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my $func_ref = $ext_functions{$_};
|
2006-06-09 18:13:09 +02:00
|
|
|
my $local_var = " " . ConvertType($func_ref->[1]) . " (*$ext_prefix$func_ref->[0])( ";
|
2008-09-25 16:48:03 +02:00
|
|
|
for (my $i = 0; $i < @{$func_ref->[2]}; $i++) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my $type = ConvertType($func_ref->[2]->[$i]->[0]);
|
2006-06-09 18:13:09 +02:00
|
|
|
$local_var .= "$type";
|
2008-09-25 16:48:03 +02:00
|
|
|
if ($i+1 < @{$func_ref->[2]}) {
|
2006-06-09 18:13:09 +02:00
|
|
|
$local_var .= ", ";
|
2000-06-12 03:21:18 +02:00
|
|
|
} else {
|
2006-06-09 18:13:09 +02:00
|
|
|
$local_var .= " ";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
2008-09-25 16:48:03 +02:00
|
|
|
$local_var .= 'void ' if (!@{$func_ref->[2]});
|
2008-12-30 12:20:47 +01:00
|
|
|
$local_var .= ") = extension_funcs[EXT_$func_ref->[0]];\n";
|
2006-06-09 18:13:09 +02:00
|
|
|
print EXT "\nstatic ", GenerateThunk($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe, $local_var);
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
2007-12-07 21:01:34 +01:00
|
|
|
# Then the table giving the string <-> function correspondence */
|
|
|
|
print EXT "\n\n/* The table giving the correspondence between names and functions */\n";
|
2008-12-30 12:20:47 +01:00
|
|
|
print EXT "const OpenGL_extension extension_registry[NB_EXTENSIONS] = {\n";
|
2005-05-20 20:58:10 +02:00
|
|
|
my $i = 0;
|
2000-06-12 03:21:18 +02:00
|
|
|
foreach (sort keys %ext_functions) {
|
2005-05-20 20:58:10 +02:00
|
|
|
my $func_ref = $ext_functions{$_};
|
2006-06-09 16:26:44 +02:00
|
|
|
if ($func_ref->[0] eq $func_ref->[3])
|
|
|
|
{
|
2008-12-30 01:07:27 +01:00
|
|
|
print EXT " { \"$func_ref->[0]\", \"$func_ref->[4]\", wine_$func_ref->[0] }";
|
2006-06-09 16:26:44 +02:00
|
|
|
}
|
2006-06-09 18:13:09 +02:00
|
|
|
if ($i != $count-1) {
|
2000-06-12 03:21:18 +02:00
|
|
|
print EXT ",";
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
print EXT "\n";
|
|
|
|
}
|
|
|
|
print EXT "};\n";
|
|
|
|
|
|
|
|
close(EXT);
|