2000-06-12 03:21:18 +02:00
|
|
|
#!/usr/bin/perl -w
|
2005-05-20 20:58:10 +02:00
|
|
|
use strict;
|
2017-10-10 10:16:03 +02:00
|
|
|
use XML::LibXML;
|
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]
|
|
|
|
#
|
2012-07-17 00:00:55 +02:00
|
|
|
# - It needs files from the OpenGL extension registry:
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
2017-08-01 00:14:38 +02:00
|
|
|
# https://raw.github.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml
|
|
|
|
# https://raw.github.com/KhronosGroup/OpenGL-Registry/master/xml/wgl.xml
|
2007-08-17 19:22:12 +02:00
|
|
|
#
|
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.
|
|
|
|
#
|
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).
|
|
|
|
#
|
2012-07-16 23:21:53 +02:00
|
|
|
# - include/wine/wgl_driver.h: definitions for the tables of OpenGL functions.
|
|
|
|
#
|
|
|
|
#
|
2002-03-10 00:29:33 +01:00
|
|
|
# Copyright 2000 Lionel Ulmer
|
2012-07-16 23:21:53 +02:00
|
|
|
# Copyright 2012 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
# 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";
|
2013-11-01 18:18:05 +01:00
|
|
|
my $wgl_driver_file = "../../include/wine/wgl_driver.h";
|
|
|
|
my $wgl_file = "../../include/wine/wgl.h";
|
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
|
|
|
|
#
|
2013-11-01 18:18:26 +01:00
|
|
|
my %cat_1_0 = ( "GL_VERSION_1_0" => 1 );
|
|
|
|
my %cat_1_1 = ( %cat_1_0, "GL_VERSION_1_1" => 1 );
|
|
|
|
my %cat_1_2 = ( %cat_1_1, "GL_VERSION_1_2" => 1 );
|
|
|
|
my %cat_1_3 = ( %cat_1_2, "GL_VERSION_1_3" => 1 );
|
|
|
|
my %cat_1_4 = ( %cat_1_3, "GL_VERSION_1_4" => 1 );
|
|
|
|
my %cat_1_5 = ( %cat_1_4, "GL_VERSION_1_5" => 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
|
|
|
|
|
|
|
#
|
2017-10-09 15:21:31 +02:00
|
|
|
# This hash table gives the conversion between OpenGL types and
|
|
|
|
# the .spec type and debug format
|
2001-03-04 02:05:20 +01:00
|
|
|
#
|
2017-10-09 15:21:31 +02:00
|
|
|
my %arg_types =
|
|
|
|
(
|
|
|
|
"GLbitfield" => [ "long", "%d" ],
|
|
|
|
"GLboolean" => [ "long", "%d" ],
|
|
|
|
"GLbyte" => [ "long", "%d" ],
|
|
|
|
"GLchar" => [ "long", "%c" ],
|
|
|
|
"GLcharARB" => [ "long", "%c" ],
|
|
|
|
"GLclampd" => [ "double", "%f" ],
|
|
|
|
"GLclampf" => [ "float", "%f" ],
|
|
|
|
"GLclampx" => [ "long", "%d" ],
|
|
|
|
"GLdouble" => [ "double", "%f" ],
|
|
|
|
"GLeglClientBufferEXT" => [ "ptr", "%p" ],
|
|
|
|
"GLenum" => [ "long", "%d" ],
|
|
|
|
"GLfixed" => [ "long", "%d" ],
|
|
|
|
"GLfloat" => [ "float", "%f" ],
|
|
|
|
"GLhalfNV" => [ "long", "%d" ],
|
|
|
|
"GLhandleARB" => [ "long", "%d" ],
|
|
|
|
"GLint" => [ "long", "%d" ],
|
|
|
|
"GLint64" => [ "int64", "wine_dbgstr_longlong(%s)" ],
|
|
|
|
"GLint64EXT" => [ "int64", "wine_dbgstr_longlong(%s)" ],
|
|
|
|
"GLintptr" => [ "long", "%ld" ],
|
|
|
|
"GLintptrARB" => [ "long", "%ld" ],
|
|
|
|
"GLshort" => [ "long", "%d" ],
|
|
|
|
"GLsizei" => [ "long", "%d" ],
|
|
|
|
"GLsizeiptr" => [ "long", "%ld" ],
|
|
|
|
"GLsizeiptrARB" => [ "long", "%ld" ],
|
|
|
|
"GLstring" => [ "str", "wine_dbgstr_a(%s)" ],
|
|
|
|
"GLsync" => [ "ptr", "%p" ],
|
|
|
|
"GLubyte" => [ "long", "%d" ],
|
|
|
|
"GLuint" => [ "long", "%d" ],
|
|
|
|
"GLuint64" => [ "int64", "wine_dbgstr_longlong(%s)" ],
|
|
|
|
"GLuint64EXT" => [ "int64", "wine_dbgstr_longlong(%s)" ],
|
|
|
|
"GLushort" => [ "long", "%d" ],
|
|
|
|
"GLvdpauSurfaceNV" => [ "long", "%ld" ],
|
|
|
|
"GLDEBUGPROC" => [ "ptr", "%p" ],
|
|
|
|
"GLDEBUGPROCARB" => [ "ptr", "%p" ],
|
|
|
|
"GLDEBUGPROCAMD" => [ "ptr", "%p" ],
|
|
|
|
"GLDEBUGPROCKHR" => [ "ptr", "%p" ],
|
|
|
|
"GLVULKANPROCNV" => [ "ptr", "%p" ],
|
|
|
|
"HDC" => [ "long", "%p" ],
|
|
|
|
"HGLRC" => [ "long", "%p" ],
|
|
|
|
"HPBUFFERARB" => [ "long", "%p" ],
|
|
|
|
"HENHMETAFILE" => [ "long", "%p" ],
|
|
|
|
"LPGLYPHMETRICSFLOAT" => [ "ptr", "%p" ],
|
|
|
|
"LPCSTR" => [ "str", "wine_dbgstr_a(%s)" ],
|
|
|
|
"UINT" => [ "long", "%u" ],
|
|
|
|
"DWORD" => [ "long", "%u" ],
|
|
|
|
"BOOL" => [ "long", "%u" ],
|
|
|
|
"FLOAT" => [ "float", "%f" ],
|
2017-10-10 10:06:10 +02:00
|
|
|
);
|
2001-03-04 02:05:20 +01:00
|
|
|
|
2017-10-09 15:21:31 +02:00
|
|
|
my %remap_types =
|
|
|
|
(
|
|
|
|
"HGLRC" => "struct wgl_context *",
|
|
|
|
"HPBUFFERARB" => "struct wgl_pbuffer *",
|
|
|
|
);
|
2003-06-20 23:29:28 +02:00
|
|
|
#
|
|
|
|
# Used to convert some types
|
|
|
|
#
|
2005-05-20 20:58:10 +02:00
|
|
|
sub ConvertType($)
|
|
|
|
{
|
2017-10-09 15:21:31 +02:00
|
|
|
my $arg = shift;
|
|
|
|
my $ret = $arg->textContent();
|
|
|
|
my @type = $arg->findnodes("./ptype");
|
|
|
|
|
|
|
|
if (@type)
|
|
|
|
{
|
|
|
|
my $type = $type[0]->textContent();
|
|
|
|
$ret =~ s/$type/$remap_types{$type}/ if defined $remap_types{$type};
|
2003-06-20 23:29:28 +02:00
|
|
|
}
|
2017-10-09 15:21:31 +02:00
|
|
|
return $ret;
|
2003-06-20 23:29:28 +02:00
|
|
|
}
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# This functions generates the thunk for a given function.
|
|
|
|
#
|
2017-09-15 15:12:26 +02:00
|
|
|
sub GenerateThunk($$$)
|
2005-05-20 20:58:10 +02:00
|
|
|
{
|
2017-09-15 15:12:26 +02:00
|
|
|
my ($name, $func_ref, $prefix) = @_;
|
2005-05-20 20:58:10 +02:00
|
|
|
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
|
|
|
|
2012-07-17 00:00:55 +02:00
|
|
|
return "" if $name eq "glDebugEntry";
|
2015-02-10 20:13:44 +01:00
|
|
|
return "" if $name eq "glGetIntegerv";
|
2012-07-17 00:00:55 +02:00
|
|
|
return "" if $name eq "glGetString";
|
2013-11-01 18:18:26 +01:00
|
|
|
return "" if $func_ref->[2] && $func_ref->[2]->[0] =~ /WGL_/;
|
2000-06-12 03:21:18 +02:00
|
|
|
|
2017-10-10 10:16:03 +02:00
|
|
|
my $ret = get_func_proto( "%s WINAPI %s(%s)", $name, $func_ref );
|
|
|
|
foreach my $arg (@{$func_ref->[1]}) {
|
|
|
|
my $ptype = get_arg_type( $arg );
|
|
|
|
my $pname = get_arg_name( $arg );
|
|
|
|
my $param = $arg->textContent();
|
|
|
|
$call_arg .= " " . $pname . ",";
|
|
|
|
if ($param =~ /\*/ || $param =~ /\[/) {
|
2017-10-09 15:21:31 +02:00
|
|
|
$trace_arg .= ", %p";
|
2017-10-10 10:16:03 +02:00
|
|
|
$trace_call_arg .= ", " . $pname;
|
2017-10-09 15:21:31 +02:00
|
|
|
} elsif (defined $arg_types{$ptype}) {
|
|
|
|
my $format = ${$arg_types{$ptype}}[1];
|
|
|
|
$trace_arg .= ", " . ($format =~ /^%/ ? $format : "%s");
|
|
|
|
$trace_call_arg .= ", " . sprintf $format =~ /^%/ ? "%s" : $format, $pname;
|
2013-11-01 18:18:14 +01:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
else { printf "Unknown type %s in %s\n", $param, $name; }
|
2001-03-04 02:05:20 +01:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
$call_arg =~ s/,$/ /;
|
2017-10-09 15:21:31 +02:00
|
|
|
$trace_arg =~ s/^, //;
|
2017-10-10 10:16:03 +02:00
|
|
|
return "$ret DECLSPEC_HIDDEN;\n" if $name eq "glGetStringi";
|
|
|
|
$ret .= "\n{\n const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;\n";
|
|
|
|
$ret .= " TRACE( \"($trace_arg)\\n\"$trace_call_arg );\n" if $gen_traces;
|
2017-10-10 10:10:41 +02:00
|
|
|
$ret .= " ";
|
2017-10-10 10:16:03 +02:00
|
|
|
$ret .= "return " unless is_void_func( $func_ref );
|
|
|
|
$ret .= "funcs->$prefix.p_$name($call_arg);\n";
|
2013-11-01 18:18:14 +01:00
|
|
|
$ret .= "}\n";
|
2005-05-20 20:58:10 +02:00
|
|
|
return $ret;
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
2012-07-17 00:00:55 +02:00
|
|
|
sub generate_null_func($$)
|
2012-07-16 23:34:45 +02:00
|
|
|
{
|
2012-07-17 00:00:55 +02:00
|
|
|
my ($name, $func_ref) = @_;
|
2012-07-16 23:34:45 +02:00
|
|
|
my $ret;
|
|
|
|
|
2012-07-17 00:00:55 +02:00
|
|
|
return "" if $name eq "glDebugEntry";
|
2012-07-16 23:34:45 +02:00
|
|
|
|
2017-10-10 10:16:03 +02:00
|
|
|
$ret = get_func_proto( "static %s null_%s(%s)", $name, $func_ref );
|
|
|
|
$ret .= " {";
|
2012-07-17 00:00:55 +02:00
|
|
|
if ($name eq "glGetError")
|
2012-07-16 23:34:45 +02:00
|
|
|
{
|
|
|
|
$ret .= " return GL_INVALID_OPERATION;";
|
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
elsif (!is_void_func( $func_ref ))
|
2012-07-16 23:34:45 +02:00
|
|
|
{
|
|
|
|
$ret .= " return 0;";
|
|
|
|
}
|
|
|
|
$ret .= " }\n";
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
2017-10-10 10:06:10 +02:00
|
|
|
sub generate_spec_entry($$)
|
|
|
|
{
|
|
|
|
my ($name, $func) = @_;
|
|
|
|
my $args=" ";
|
|
|
|
foreach my $arg (@{$func->[1]})
|
|
|
|
{
|
2017-10-10 10:16:03 +02:00
|
|
|
my $ptype = get_arg_type( $arg );
|
|
|
|
my $param = $arg->textContent();
|
|
|
|
if ($param =~ /[[*]/) {
|
2017-10-10 10:06:10 +02:00
|
|
|
$args .= "ptr ";
|
2017-10-09 15:21:31 +02:00
|
|
|
} elsif (defined($arg_types{$ptype})) {
|
|
|
|
$args .= "$@$arg_types{$ptype}[0] ";
|
2017-10-10 10:06:10 +02:00
|
|
|
} else {
|
2017-10-10 10:16:03 +02:00
|
|
|
die "No conversion for func $name type $param\n";
|
2017-10-10 10:06:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$args = substr($args,1,-1);
|
|
|
|
return "@ stdcall $_($args)";
|
|
|
|
}
|
|
|
|
|
2017-10-10 10:16:03 +02:00
|
|
|
sub is_void_func($)
|
|
|
|
{
|
|
|
|
my $func = shift;
|
|
|
|
return 0 if @{$func->[0]->findnodes("./ptype")};
|
|
|
|
return $func->[0]->textContent() eq "void ";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_arg_type($)
|
|
|
|
{
|
|
|
|
my $p = shift;
|
|
|
|
my @type = $p->findnodes("./ptype");
|
|
|
|
return @type ? $type[0]->textContent() : "GLint";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_arg_name($)
|
|
|
|
{
|
|
|
|
my $p = shift;
|
|
|
|
my @name = $p->findnodes("./name");
|
|
|
|
return $name[0]->textContent();
|
|
|
|
}
|
|
|
|
|
2012-11-07 13:14:58 +01:00
|
|
|
sub get_func_proto($$$)
|
2012-07-16 23:21:53 +02:00
|
|
|
{
|
2012-11-07 13:14:58 +01:00
|
|
|
my ($format, $name, $func) = @_;
|
2017-10-10 10:06:10 +02:00
|
|
|
die "unknown func $name" unless defined $func->[0];
|
2017-10-09 15:21:31 +02:00
|
|
|
my $proto = ConvertType( $func->[0] );
|
2017-10-10 10:16:03 +02:00
|
|
|
$proto =~ s/ $//;
|
|
|
|
my $args = "";
|
|
|
|
foreach my $arg (@{$func->[1]})
|
2012-07-16 23:21:53 +02:00
|
|
|
{
|
2017-10-09 15:21:31 +02:00
|
|
|
$args .= " " . ConvertType( $arg ) . ",";
|
2012-07-16 23:21:53 +02:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
$args =~ s/,$/ /;
|
|
|
|
$args ||= "void";
|
|
|
|
return sprintf $format, $proto, $name, $args;
|
2012-07-16 23:21:53 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
#
|
2017-08-01 00:14:38 +02:00
|
|
|
-f "gl.xml" || system "wget https://raw.github.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml" || die "cannot download gl.xml";
|
|
|
|
-f "wgl.xml" || system "wget https://raw.github.com/KhronosGroup/OpenGL-Registry/master/xml/wgl.xml" || die "cannot download wgl.xml";
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
#
|
2013-11-01 18:18:26 +01:00
|
|
|
# Then, create the list of all OpenGL functions using the registry
|
|
|
|
# files. This will create two hash-tables, one with all the function
|
2000-06-12 03:21:18 +02:00
|
|
|
# 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 :
|
|
|
|
#
|
2017-10-10 10:16:03 +02:00
|
|
|
# - XML node of the function prototype
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
2017-10-10 10:16:03 +02:00
|
|
|
# - reference to an array of XML nodes giving the list of arguments (an empty array
|
2000-06-12 03:21:18 +02:00
|
|
|
# for a 'void' function).
|
|
|
|
#
|
2017-10-09 20:13:01 +02:00
|
|
|
my %norm_functions;
|
|
|
|
my %ext_functions;
|
2017-10-10 10:06:10 +02:00
|
|
|
my %wgl_functions;
|
2017-10-09 15:21:31 +02:00
|
|
|
my (%gl_types, @gl_types); # also use an array to preserve declaration order
|
2017-10-10 10:06:10 +02:00
|
|
|
|
|
|
|
my %supported_wgl_functions =
|
|
|
|
(
|
|
|
|
"wglCopyContext" => 1,
|
|
|
|
"wglCreateContext" => 1,
|
|
|
|
"wglDeleteContext" => 1,
|
|
|
|
"wglDescribePixelFormat" => 1,
|
|
|
|
"wglGetPixelFormat" => 1,
|
|
|
|
"wglGetProcAddress" => 1,
|
|
|
|
"wglMakeCurrent" => 1,
|
|
|
|
"wglSetPixelFormat" => 1,
|
|
|
|
"wglShareLists" => 1,
|
|
|
|
"wglSwapBuffers" => 1,
|
|
|
|
);
|
2012-07-18 23:58:41 +02:00
|
|
|
|
2017-10-10 10:06:10 +02:00
|
|
|
my %remapped_wgl_functions =
|
|
|
|
(
|
|
|
|
"ChoosePixelFormat" => "wglChoosePixelFormat",
|
|
|
|
"DescribePixelFormat" => "wglDescribePixelFormat",
|
|
|
|
"GetPixelFormat" => "wglGetPixelFormat",
|
|
|
|
"GetEnhMetaFilePixelFormat" => 0,
|
|
|
|
"SetPixelFormat" => "wglSetPixelFormat",
|
|
|
|
"SwapBuffers" => "wglSwapBuffers",
|
|
|
|
"wglUseFontBitmaps" => 0,
|
|
|
|
"wglUseFontOutlines" => 0,
|
|
|
|
);
|
2012-07-18 23:58:41 +02:00
|
|
|
|
2012-07-17 00:00:55 +02:00
|
|
|
my %supported_wgl_extensions =
|
|
|
|
(
|
|
|
|
"WGL_ARB_create_context" => 1,
|
|
|
|
"WGL_ARB_extensions_string" => 1,
|
|
|
|
"WGL_ARB_make_current_read" => 1,
|
|
|
|
"WGL_ARB_pbuffer" => 1,
|
|
|
|
"WGL_ARB_pixel_format" => 1,
|
|
|
|
"WGL_ARB_render_texture" => 1,
|
|
|
|
"WGL_EXT_extensions_string" => 1,
|
|
|
|
"WGL_EXT_swap_control" => 1,
|
|
|
|
"WGL_NV_vertex_array_range" => 1,
|
|
|
|
"WGL_WINE_pixel_format_passthrough" => 1,
|
2017-10-09 20:13:01 +02:00
|
|
|
"WGL_WINE_query_renderer" => 1,
|
2012-07-17 00:00:55 +02:00
|
|
|
);
|
|
|
|
|
2017-10-09 20:13:01 +02:00
|
|
|
my %enums;
|
2013-11-01 18:18:26 +01:00
|
|
|
|
2017-10-10 10:16:03 +02:00
|
|
|
my %supported_apis =
|
|
|
|
(
|
|
|
|
"gl" => 1,
|
|
|
|
);
|
|
|
|
|
|
|
|
sub is_supported_api($)
|
2012-07-17 00:00:55 +02:00
|
|
|
{
|
2017-10-10 10:16:03 +02:00
|
|
|
my $api = shift;
|
|
|
|
foreach my $i (split /\|/, $api)
|
|
|
|
{
|
|
|
|
return 1 if defined $supported_apis{$i};
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
return 0;
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
2013-11-01 18:18:26 +01:00
|
|
|
sub parse_file($$)
|
2012-11-07 13:14:58 +01:00
|
|
|
{
|
2013-11-01 18:18:26 +01:00
|
|
|
my ($file, $generate_enums) = @_;
|
2017-10-10 10:16:03 +02:00
|
|
|
my $xml = XML::LibXML->load_xml( location => $file );
|
2013-11-01 18:18:26 +01:00
|
|
|
my %functions;
|
|
|
|
|
|
|
|
# save all functions
|
2017-10-10 10:16:03 +02:00
|
|
|
foreach my $command ($xml->findnodes("/registry/commands/command"))
|
|
|
|
{
|
|
|
|
my $proto = @{$command->findnodes("./proto")}[0];
|
|
|
|
my $name = @{$command->findnodes("./proto/name")}[0];
|
|
|
|
$proto->removeChild( $name );
|
|
|
|
my @params = $command->findnodes("./param");
|
|
|
|
$functions{$name->textContent()} = [ $proto, \@params ];
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# save all enums (only GL)
|
2017-10-10 10:16:03 +02:00
|
|
|
if ($generate_enums)
|
|
|
|
{
|
|
|
|
foreach my $enum ($xml->findnodes("/registry/enums/enum"))
|
|
|
|
{
|
|
|
|
$enums{$enum->{name}} = $enum->{value};
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-09 15:21:31 +02:00
|
|
|
# save all types
|
|
|
|
foreach my $type ($xml->findnodes("/registry/types/type"))
|
|
|
|
{
|
|
|
|
next if $type->{api};
|
|
|
|
my $name = @{$type->findnodes("./name")}[0];
|
|
|
|
next unless $name;
|
|
|
|
$name = $name->textContent;
|
|
|
|
push @gl_types, $name unless $gl_types{$name};
|
|
|
|
$gl_types{$name} = $type;
|
|
|
|
}
|
|
|
|
|
2013-11-01 18:18:26 +01:00
|
|
|
# generate norm functions
|
2017-10-10 10:16:03 +02:00
|
|
|
foreach my $feature ($xml->findnodes("/registry/feature"))
|
|
|
|
{
|
|
|
|
if ($feature->{api} eq "wgl")
|
|
|
|
{
|
|
|
|
foreach my $cmd ($feature->findnodes("./require/command"))
|
|
|
|
{
|
|
|
|
my $name = $cmd->{name};
|
|
|
|
if (defined $remapped_wgl_functions{$name})
|
|
|
|
{
|
|
|
|
next unless $remapped_wgl_functions{$name};
|
|
|
|
$name = $remapped_wgl_functions{$name};
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
$wgl_functions{$name} = $functions{$cmd->{name}};
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
next unless defined $norm_categories{$feature->{name}};
|
|
|
|
foreach my $cmd ($feature->findnodes("./require/command"))
|
|
|
|
{
|
|
|
|
$norm_functions{$cmd->{name}} = $functions{$cmd->{name}};
|
|
|
|
}
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# generate extension functions from norm functions, if they are newer than the category
|
2017-10-10 10:16:03 +02:00
|
|
|
foreach my $feature ($xml->findnodes("/registry/feature"))
|
|
|
|
{
|
|
|
|
next if defined $norm_categories{$feature->{name}};
|
|
|
|
next unless is_supported_api( $feature->{api} );
|
|
|
|
foreach my $cmd ($feature->findnodes("./require/command"))
|
2017-10-10 10:06:10 +02:00
|
|
|
{
|
2017-10-10 10:16:03 +02:00
|
|
|
my $name = $cmd->{name};
|
|
|
|
next if $norm_functions{$name} || $ext_functions{$name};
|
|
|
|
$ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $feature->{name} ] ];
|
2017-10-10 10:06:10 +02:00
|
|
|
}
|
2012-11-07 13:14:58 +01:00
|
|
|
}
|
|
|
|
|
2013-11-01 18:18:26 +01:00
|
|
|
# generate extension functions
|
2017-10-10 10:16:03 +02:00
|
|
|
foreach my $ext ($xml->findnodes("/registry/extensions/extension"))
|
|
|
|
{
|
|
|
|
if ($ext->{supported} eq "wgl")
|
|
|
|
{
|
|
|
|
next unless defined $supported_wgl_extensions{$ext->{name}};
|
|
|
|
foreach my $cmd ($ext->findnodes("./require/command"))
|
|
|
|
{
|
|
|
|
my $name = $cmd->{name};
|
|
|
|
$ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $ext->{name} ] ];
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
next;
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
2017-10-10 10:16:03 +02:00
|
|
|
next unless is_supported_api( $ext->{supported} );
|
|
|
|
foreach my $req ($ext->findnodes("./require"))
|
|
|
|
{
|
|
|
|
next unless !$req->{api} || $req->{api} eq "gl";
|
|
|
|
foreach my $cmd ($req->findnodes("./command"))
|
|
|
|
{
|
|
|
|
my $name = $cmd->{name};
|
|
|
|
next if $norm_functions{$name};
|
|
|
|
if (!$ext_functions{$name})
|
|
|
|
{
|
|
|
|
$ext_functions{$name} = [ $functions{$name}[0], $functions{$name}[1], [ $ext->{name} ] ];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push @{$ext_functions{$name}->[2]}, $ext->{name};
|
2013-11-01 18:18:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-06-12 03:21:18 +02:00
|
|
|
|
2013-11-01 18:18:26 +01:00
|
|
|
parse_file( "gl.xml", 1 );
|
|
|
|
parse_file( "wgl.xml", 0 );
|
2017-10-09 20:13:01 +02:00
|
|
|
parse_file( "winegl.xml", 1 );
|
2012-11-07 13:14:58 +01:00
|
|
|
|
2012-07-16 23:21:53 +02:00
|
|
|
#
|
|
|
|
# Get the current wgl_driver.h version
|
|
|
|
#
|
|
|
|
my $wgl_version = 0;
|
2013-11-01 18:18:05 +01:00
|
|
|
open HEADER, "<$wgl_driver_file" or die "cannot open $wgl_driver_file";
|
2012-07-16 23:21:53 +02:00
|
|
|
while (<HEADER>)
|
|
|
|
{
|
|
|
|
next unless /^#define WINE_WGL_DRIVER_VERSION (\d+)/;
|
|
|
|
$wgl_version = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
close HEADER;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate the wgl_driver.h file
|
|
|
|
#
|
2013-11-01 18:18:05 +01:00
|
|
|
open HEADER, ">$wgl_driver_file" or die "cannot create $wgl_driver_file";
|
|
|
|
print HEADER "/* Automatically generated from http://www.opengl.org/registry files; DO NOT EDIT! */\n\n";
|
2012-07-16 23:21:53 +02:00
|
|
|
print HEADER "#ifndef __WINE_WGL_DRIVER_H\n";
|
|
|
|
print HEADER "#define __WINE_WGL_DRIVER_H\n\n";
|
|
|
|
print HEADER "#ifndef WINE_GLAPI\n";
|
|
|
|
print HEADER "#define WINE_GLAPI\n";
|
|
|
|
print HEADER "#endif\n\n";
|
|
|
|
|
|
|
|
printf HEADER "#define WINE_WGL_DRIVER_VERSION %u\n\n", $wgl_version + 1;
|
|
|
|
|
2012-07-20 12:25:01 +02:00
|
|
|
print HEADER "struct wgl_context;\n";
|
|
|
|
print HEADER "struct wgl_pbuffer;\n\n";
|
2012-07-18 23:58:41 +02:00
|
|
|
|
2012-07-16 23:21:53 +02:00
|
|
|
print HEADER "struct opengl_funcs\n{\n";
|
2012-07-18 23:58:41 +02:00
|
|
|
print HEADER " struct\n {\n";
|
|
|
|
foreach (sort keys %wgl_functions)
|
|
|
|
{
|
2017-10-10 10:06:10 +02:00
|
|
|
next unless defined $supported_wgl_functions{$_};
|
2017-10-10 10:16:03 +02:00
|
|
|
print HEADER get_func_proto(" %-10s (WINE_GLAPI *p_%s)(%s);\n", $_, $wgl_functions{$_});
|
2012-07-18 23:58:41 +02:00
|
|
|
}
|
|
|
|
print HEADER " } wgl;\n\n";
|
|
|
|
|
2012-07-16 23:21:53 +02:00
|
|
|
print HEADER " struct\n {\n";
|
|
|
|
foreach (sort keys %norm_functions)
|
|
|
|
{
|
|
|
|
next if $_ eq "glDebugEntry";
|
2017-10-10 10:16:03 +02:00
|
|
|
print HEADER get_func_proto(" %-10s (WINE_GLAPI *p_%s)(%s);\n", $_, $norm_functions{$_});
|
2012-07-16 23:21:53 +02:00
|
|
|
}
|
|
|
|
print HEADER " } gl;\n\n";
|
|
|
|
|
|
|
|
print HEADER " struct\n {\n";
|
|
|
|
foreach (sort keys %ext_functions)
|
|
|
|
{
|
2017-10-10 10:16:03 +02:00
|
|
|
print HEADER get_func_proto(" %-10s (WINE_GLAPI *p_%s)(%s);\n", $_, $ext_functions{$_});
|
2012-07-16 23:21:53 +02:00
|
|
|
}
|
|
|
|
print HEADER " } ext;\n";
|
|
|
|
print HEADER "};\n\n";
|
|
|
|
|
|
|
|
print HEADER "#define ALL_WGL_FUNCS";
|
|
|
|
foreach (sort keys %norm_functions)
|
|
|
|
{
|
|
|
|
next if $_ eq "glDebugEntry";
|
|
|
|
printf HEADER " \\\n USE_GL_FUNC(\%s)", $_;
|
|
|
|
}
|
|
|
|
print HEADER "\n\n";
|
|
|
|
|
2012-11-05 00:28:51 +01:00
|
|
|
print HEADER "extern struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );\n";
|
|
|
|
print HEADER "extern BOOL CDECL __wine_set_pixel_format( HWND hwnd, int format );\n\n";
|
2012-07-16 23:21:53 +02:00
|
|
|
print HEADER "#endif /* __WINE_WGL_DRIVER_H */\n";
|
|
|
|
close HEADER;
|
|
|
|
|
2012-11-07 13:14:58 +01:00
|
|
|
#
|
|
|
|
# Generate the wgl.h file
|
|
|
|
#
|
2013-11-01 18:18:05 +01:00
|
|
|
open HEADER, ">$wgl_file" or die "cannot create $wgl_file";
|
|
|
|
print HEADER "/* Automatically generated from http://www.opengl.org/registry files; DO NOT EDIT! */\n\n";
|
2012-11-07 13:14:58 +01:00
|
|
|
print HEADER "#ifndef __WINE_WGL_H\n";
|
|
|
|
print HEADER "#define __WINE_WGL_H\n\n";
|
|
|
|
|
|
|
|
print HEADER "#ifndef GLAPIENTRY\n";
|
|
|
|
print HEADER "#define GLAPIENTRY __stdcall\n";
|
|
|
|
print HEADER "#endif\n\n";
|
|
|
|
|
2017-10-10 10:16:03 +02:00
|
|
|
print HEADER "#undef near\n";
|
|
|
|
print HEADER "#undef far\n\n";
|
|
|
|
|
2017-10-09 15:21:31 +02:00
|
|
|
foreach (@gl_types)
|
2012-11-07 13:14:58 +01:00
|
|
|
{
|
2017-10-09 15:21:31 +02:00
|
|
|
printf HEADER $gl_types{$_}->textContent() . "\n";
|
2012-11-07 13:14:58 +01:00
|
|
|
}
|
|
|
|
print HEADER "\n";
|
|
|
|
|
|
|
|
my $maxlen = 1;
|
|
|
|
foreach (keys %enums) { $maxlen = length($_) if length($_) > $maxlen; }
|
|
|
|
foreach (sort keys %enums)
|
|
|
|
{
|
|
|
|
printf HEADER "#define %-*s %s\n", $maxlen, $_, $enums{$_};
|
|
|
|
}
|
|
|
|
print HEADER "\n";
|
|
|
|
|
|
|
|
foreach (sort keys %norm_functions)
|
|
|
|
{
|
2017-10-10 10:16:03 +02:00
|
|
|
printf HEADER "%s;\n", get_func_proto("%-10s GLAPIENTRY %s(%s)", $_, $norm_functions{$_});
|
2012-11-07 13:14:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
print HEADER "\n#endif /* __WINE_WGL_H */\n";
|
|
|
|
close HEADER;
|
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
#
|
|
|
|
# Now, generate the output files. First, the spec file.
|
|
|
|
#
|
2013-11-01 18:18:26 +01:00
|
|
|
open(SPEC, ">$spec_file") or die "cannot create $spec_file";
|
2000-06-12 03:21:18 +02:00
|
|
|
|
|
|
|
foreach (sort keys %norm_functions) {
|
2017-10-10 10:06:10 +02:00
|
|
|
printf SPEC "%s\n", generate_spec_entry( $_, $norm_functions{$_} );
|
|
|
|
}
|
|
|
|
foreach (sort keys %wgl_functions) {
|
|
|
|
printf SPEC "%s\n", generate_spec_entry( $_, $wgl_functions{$_} );
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2006-12-12 17:59:44 +01:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
close(SPEC);
|
|
|
|
|
|
|
|
#
|
|
|
|
# After the spec file, the opengl_norm.c file
|
|
|
|
#
|
2013-11-01 18:18:26 +01:00
|
|
|
open(NORM, ">$norm_file") or die "cannot create $norm_file";
|
2000-06-12 03:21:18 +02:00
|
|
|
print NORM "
|
|
|
|
/* Auto-generated file... Do not edit ! */
|
|
|
|
|
|
|
|
#include \"config.h\"
|
2012-07-16 23:34:45 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include \"winternl.h\"
|
2012-07-30 21:53:37 +02:00
|
|
|
#include \"wingdi.h\"
|
2012-11-07 13:15:24 +01:00
|
|
|
#include \"wine/wgl.h\"
|
2012-07-16 23:34:45 +02:00
|
|
|
#include \"wine/wgl_driver.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
|
|
|
";
|
|
|
|
|
2012-07-16 23:39:31 +02:00
|
|
|
foreach (sort keys %norm_functions) {
|
2017-09-15 15:12:26 +02:00
|
|
|
my $string = GenerateThunk($_, $norm_functions{$_}, "gl");
|
2006-12-12 17:59:44 +01:00
|
|
|
print NORM "\n$string" if $string;
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
2012-07-16 23:34:45 +02:00
|
|
|
|
2012-07-18 23:58:41 +02:00
|
|
|
foreach (sort keys %wgl_functions) {
|
2017-10-10 10:06:10 +02:00
|
|
|
next unless defined $supported_wgl_functions{$_};
|
2012-07-18 23:58:41 +02:00
|
|
|
print NORM generate_null_func($_, $wgl_functions{$_});
|
|
|
|
}
|
2012-07-16 23:34:45 +02:00
|
|
|
foreach (sort keys %norm_functions) {
|
2012-07-17 00:00:55 +02:00
|
|
|
print NORM generate_null_func($_, $norm_functions{$_});
|
2012-07-16 23:34:45 +02:00
|
|
|
}
|
2012-08-23 21:23:09 +02:00
|
|
|
foreach (sort keys %ext_functions) {
|
|
|
|
print NORM generate_null_func($_, $ext_functions{$_});
|
|
|
|
}
|
2012-07-16 23:34:45 +02:00
|
|
|
|
2012-07-18 23:58:41 +02:00
|
|
|
print NORM "\nstruct opengl_funcs null_opengl_funcs =\n{\n {\n";
|
2017-10-10 10:06:10 +02:00
|
|
|
foreach (sort keys %wgl_functions)
|
|
|
|
{
|
|
|
|
next unless defined $supported_wgl_functions{$_};
|
|
|
|
print NORM " null_$_,\n";
|
|
|
|
}
|
2012-08-23 21:23:09 +02:00
|
|
|
print NORM " },\n {\n";
|
|
|
|
foreach (sort keys %norm_functions) { print NORM " null_$_,\n" unless $_ eq "glDebugEntry"; }
|
|
|
|
print NORM " },\n {\n";
|
|
|
|
foreach (sort keys %ext_functions) { print NORM " null_$_,\n"; }
|
|
|
|
print NORM " }\n};\n";
|
2012-07-16 23:34:45 +02:00
|
|
|
|
2000-06-12 03:21:18 +02:00
|
|
|
close(NORM);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Finally, more complex, the opengl_ext.c file
|
|
|
|
#
|
2013-11-01 18:18:26 +01:00
|
|
|
open(EXT, ">$ext_file") or die "cannot create $ext_file";
|
2000-06-12 03:21:18 +02:00
|
|
|
print EXT "
|
|
|
|
/* Auto-generated file... Do not edit ! */
|
|
|
|
|
|
|
|
#include \"config.h\"
|
2012-07-18 13:07:08 +02:00
|
|
|
#include <stdarg.h>
|
2002-09-25 02:29:56 +02:00
|
|
|
#include \"opengl_ext.h\"
|
2012-07-18 13:07:08 +02:00
|
|
|
#include \"winternl.h\"
|
2012-07-30 21:53:37 +02:00
|
|
|
#include \"wingdi.h\"
|
2012-11-07 13:15:24 +01:00
|
|
|
#include \"wine/wgl.h\"
|
2012-07-17 00:00:55 +02:00
|
|
|
#define WGL_WGLEXT_PROTOTYPES
|
|
|
|
#include \"wine/wglext.h\"
|
2012-07-18 13:07:08 +02:00
|
|
|
#include \"wine/wgl_driver.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;
|
2012-07-18 13:07:08 +02:00
|
|
|
print EXT "const int extension_registry_size = $count;\n";
|
2000-06-12 03:21:18 +02:00
|
|
|
foreach (sort keys %ext_functions) {
|
2017-09-15 15:12:26 +02:00
|
|
|
my $string = GenerateThunk($_, $ext_functions{$_}, "ext");
|
2015-02-10 20:13:44 +01:00
|
|
|
if ($string =~ /DECLSPEC_HIDDEN/) {
|
|
|
|
print EXT "\n$string";
|
|
|
|
} else {
|
|
|
|
print EXT "\nstatic $string" if $string;
|
|
|
|
}
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
2007-12-07 21:01:34 +01:00
|
|
|
# Then the table giving the string <-> function correspondence */
|
2012-07-17 00:00:55 +02:00
|
|
|
print EXT "\nconst OpenGL_extension extension_registry[$count] = {\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{$_};
|
2013-11-01 18:18:26 +01:00
|
|
|
printf EXT " { \"%s\", \"%s\", %s }", $_, join(" ", sort @{$func_ref->[2]}), $_;
|
2006-06-09 18:13:09 +02:00
|
|
|
if ($i != $count-1) {
|
2013-11-01 18:18:14 +01:00
|
|
|
print EXT ",";
|
2000-06-12 03:21:18 +02:00
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
print EXT "\n";
|
|
|
|
}
|
|
|
|
print EXT "};\n";
|
|
|
|
|
|
|
|
close(EXT);
|