4 # This script is called thus :
6 # make_opengl path_to_spec_file opengl_version
8 # - path_to_spec_file is the path to the directory where the OpenGL
9 # spec files are located. These files are hosted in the OpenGL
10 # extension registry at opengl.org:
11 # http://www.opengl.org/registry/api/gl.spec
12 # http://www.opengl.org/registry/api/gl.tm
14 # The files used to be hosted and maintained by SGI. You can still find
15 # find them in the sample implementation CVS tree which is located at
16 # CVS_ROOT/projects/ogl-sample/main/doc/registry/specs.
17 # You can also find them on the web at the following URL :
18 # http://oss.sgi.com/cgi-bin/cvsweb.cgi/projects/ogl-sample/main/doc/registry/specs/
20 # - opengl_version is the OpenGL version emulated by the library
21 # (can be 1.0 to 1.5).
23 # This script generates the three following files :
25 # - opengl32.spec : the spec file giving all the exported functions
26 # of the OpenGL32.DLL library. These functions are the one an
27 # application can directly link to (and are all the functions
28 # defined in the OpenGL core for the version defined by
31 # - opengl_norm.c : this file contains the thunks for all OpenGL
32 # functions that are defined in 'opengl32.spec'. The corresponding
33 # functions NEED to be defined in Linux's libGL or the library
34 # won't be able to be linked in.
36 # - opengl_ext.c : in this file are stored thunks for ALL possible
37 # OpenGL extensions (at least, all the extensions that are defined
38 # in the OpenGL extension registry). Contrary to 'opengl_norm.c',
39 # you do not need to have these extensions in your libGL to have
40 # OpenGL work (as they are resolved at run-time using
41 # glXGetProcAddressARB).
43 # Copyright 2000 Lionel Ulmer
45 # This library is free software; you can redistribute it and/or
46 # modify it under the terms of the GNU Lesser General Public
47 # License as published by the Free Software Foundation; either
48 # version 2.1 of the License, or (at your option) any later version.
50 # This library is distributed in the hope that it will be useful,
51 # but WITHOUT ANY WARRANTY; without even the implied warranty of
52 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
53 # Lesser General Public License for more details.
55 # You should have received a copy of the GNU Lesser General Public
56 # License along with this library; if not, write to the Free Software
57 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
63 my $spec_file = "opengl32.spec";
64 my $norm_file = "opengl_norm.c";
65 my $ext_file = "opengl_ext.c";
67 # Set to 0 for removing the ENTER / LEAVE GL calls
68 my $gen_thread_safe = 1;
69 # Prefix used for the local variables
70 my $ext_prefix = "func_";
71 # If set to 1, generate TRACEs for each OpenGL function
75 # List of categories to put in the 'opengl_norm.c' file
77 my %cat_1_0 = ( "display-list" => 1,
79 "drawing-control" => 1,
88 my %cat_1_1 = ( %cat_1_0,
90 my %cat_1_2 = ( %cat_1_1,
92 my %cat_1_3 = ( %cat_1_2,
94 my %cat_1_4 = ( %cat_1_3,
96 my %cat_1_5 = ( %cat_1_4,
99 my %norm_categories = ();
102 # This hash table gives the conversion between OpenGL types and what
103 # is used by the TRACE printfs
106 ("GLbitfield" => "%d",
122 "GLintptrARB" => "%d",
123 "GLsizeiptrARB" => "%d",
125 "GLsizeiptr" => "%d",
126 "GLhandleARB" => "%d",
128 "GLvoid" => "(void)",
129 "_GLfuncptr" => "%p");
132 # This hash table gives the conversion between OpenGL types and what
133 # is used in the .spec file
136 ("GLbitfield" => [ "long", 4 ],
137 "GLboolean" => [ "long", 4 ],
138 "GLbyte" => [ "long", 4 ],
139 "GLclampd" => [ "double", 8 ],
140 "GLclampf" => [ "long", 4 ],
141 "GLdouble" => [ "double", 8 ],
142 "GLenum" => [ "long", 4 ],
143 "GLfloat" => [ "long", 4 ],
144 "GLint" => [ "long", 4 ],
145 "GLshort" => [ "long", 4 ],
146 "GLsizei" => [ "long", 4 ],
147 "GLstring" => [ "str", 4 ],
148 "GLubyte" => [ "long", 4 ],
149 "GLuint" => [ "long", 4 ],
150 "GLushort" => [ "long", 4 ],
151 "GLhalfNV" => [ "long", 4 ],
152 "GLintptrARB" => [ "long", 4 ],
153 "GLsizeiptrARB" => [ "long", 4 ],
154 "GLhandleARB" => [ "long", 4 ],
155 "GLcharARB" => [ "long", 4 ],
156 "GLintptr" => [ "long", 4 ],
157 "GLsizeiptr" => [ "long", 4 ],
158 "GLvoid" => [ "void", 4 ],
159 "_GLfuncptr" => [ "ptr", 4 ]);
162 # Used to convert some types
168 my %hash = ( "GLstring" => "const GLubyte *",
169 "GLintptrARB" => "ptrdiff_t",
170 "GLsizeiptrARB" => "ptrdiff_t",
171 "GLintptr" => "ptrdiff_t",
172 "GLsizeiptr" => "ptrdiff_t",
173 "GLhandleARB" => "unsigned int",
174 "GLcharARB" => "char",
176 "GLhalfNV" => "unsigned short" );
178 foreach my $org (reverse sort keys %hash) {
179 if ($type =~ /$org/) {
180 my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
181 return "$before$hash{$org}$after";
188 # Used to convert some variable names
190 sub ConvertVarName
($)
194 my %hash = ( "near" => "nearParam",
195 "far" => "farParam" );
197 foreach my $org (keys %hash) {
198 if ($type =~ /$org/) {
199 my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
200 return "$before$hash{$org}$after";
207 # This functions generates the thunk for a given function.
209 sub GenerateThunk
($$$$$)
211 my ($func_ref, $comment, $prefix, $thread_safe, $local_var) = @_;
216 return "" if $func_ref->[0] eq "glGetString";
217 return "" if $func_ref->[0] eq "glGetIntegerv";
218 return "" if $func_ref->[0] eq "glEnable";
219 return "" if $func_ref->[0] eq "glIsEnabled";
220 return "" if $func_ref->[0] eq "glDisable";
221 return "" if $func_ref->[0] eq "glScissor";
222 return "" if $func_ref->[0] eq "glViewport";
224 # If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
225 # Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
227 $ret = "$ret/***********************************************************************\n";
228 $ret = "$ret * $func_ref->[0] (OPENGL32.\@)\n";
231 $ret = $ret . ConvertType
($func_ref->[1]) . " WINAPI wine_$func_ref->[0]( ";
232 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
233 ## Quick debug code :-)
234 ## print $func_ref->[2]->[$i]->[1] . "\n";
235 my $type = $func_ref->[2]->[$i]->[0];
236 my $name = ConvertVarName
($func_ref->[2]->[$i]->[1]);
237 $ret = $ret . ConvertType
($type) . " $name";
238 $call_arg = "$call_arg$name";
240 $trace_arg = "$trace_arg\%p";
242 $trace_arg = "$trace_arg$debug_conv{$type}";
244 if ($i != $#{@{$func_ref->[2]}}) {
246 $call_arg = "$call_arg, ";
247 $trace_arg = "$trace_arg, ";
250 $call_arg = "$call_arg ";
253 $ret .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
255 if ($func_ref->[1] ne "void") {
256 $ret = "$ret " . ConvertType
($func_ref->[1]) . " ret_value;\n";
260 $ret = "$ret TRACE(\"($trace_arg)\\n\"";
261 if ($trace_arg ne "") {
262 $ret = "$ret, $call_arg";
267 $ret = "$ret ENTER_GL();\n";
270 if ($func_ref->[1] ne "void") {
271 $ret = $ret . "ret_value = ";
273 $ret = "$ret$prefix$func_ref->[0]( $call_arg);\n";
275 $ret = "$ret LEAVE_GL();\n";
277 if ($func_ref->[1] ne "void") {
278 $ret = "$ret return ret_value;\n"
282 # Return this string....
287 # Extract and checks the number of arguments
292 die "Usage: $name0 OpenGL_registry_location OpenGL_version\n";
294 my $registry_path = shift @ARGV;
295 my $version = shift @ARGV;
296 if ($version eq "1.0") {
297 %norm_categories = %cat_1_0;
298 } elsif ($version eq "1.1") {
299 %norm_categories = %cat_1_1;
300 } elsif ($version eq "1.2") {
301 %norm_categories = %cat_1_2;
302 } elsif ($version eq "1.3") {
303 %norm_categories = %cat_1_3;
304 } elsif ($version eq "1.4") {
305 %norm_categories = %cat_1_4;
306 } elsif ($version eq "1.5") {
307 %norm_categories = %cat_1_5;
309 die "Incorrect OpenGL version.\n";
313 # Open the registry files
315 open(TYPES
, "$registry_path/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
316 open(REGISTRY
, "$registry_path/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
319 # First, create a mapping between the pseudo types used in the spec file
320 # and OpenGL types using the 'gl.tm' file.
322 my %pseudo_to_opengl = ();
323 while (my $line = <TYPES
>) {
324 if ($line !~ /\w*\#/) {
325 my ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
326 $pseudo_to_opengl{$pseudo} = $opengl;
329 # This is to override the 'void' -> '*' bogus conversion
330 $pseudo_to_opengl{"void"} = "void";
333 # Then, create the list of all OpenGL functions using the 'gl.spec'
334 # file. This will create two hash-tables, one with all the function
335 # whose category matches the one listed in '@norm_categories', the other
336 # with all other functions.
338 # An element of the hash table is a reference to an array with these
345 # - reference to an array giving the list of arguments (an empty array
346 # for a 'void' function).
348 # The list of arguments is itself an array of reference to arrays. Each
349 # of these arrays represents the argument type and the argument name.
353 # void glBitmap( GLsizei width, GLsizei height,
354 # GLfloat xorig, GLfloat yorig,
355 # GLfloat xmove, GLfloat ymove,
356 # const GLubyte *bitmap );
358 # Would give something like that :
362 # [ [ "GLsizei", "width" ],
363 # [ "GLsizei", "height" ],
364 # [ "GLfloat", "xorig" ],
365 # [ "GLfloat", "yorig" ],
366 # [ "GLfloat", "xmove" ],
367 # [ "GLfloat", "ymove" ],
368 # [ "GLubyte *", "bitmap"] ] ];
370 my %norm_functions = ();
373 # This stores various extensions NOT part of the GL extension registry but still
374 # implemented by most OpenGL libraries out there...
378 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion", "GL_KTX_buffer_region" ],
379 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
382 [ "GLsizei", "width" ],
383 [ "GLsizei", "height" ] ], "glReadBufferRegion", "GL_KTX_buffer_region" ],
384 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
387 [ "GLsizei", "width" ],
388 [ "GLsizei", "height" ],
389 [ "GLint", "xDest" ],
390 [ "GLint", "yDest" ] ], "glDrawBufferRegion", "GL_KTX_buffer_region" ],
391 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled", "GL_KTX_buffer_region" ],
392 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion", "GL_KTX_buffer_region" ],
393 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
395 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS", "GL_SGIS_multitexture" ],
396 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
397 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
398 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
399 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS", "GL_SGIS_multitexture" ],
400 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
401 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS", "GL_SGIS_multitexture" ],
402 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
403 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS", "GL_SGIS_multitexture" ],
404 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
405 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS", "GL_SGIS_multitexture" ],
406 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
407 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS", "GL_SGIS_multitexture" ],
408 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
409 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS", "GL_SGIS_multitexture" ],
410 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
411 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS", "GL_SGIS_multitexture" ],
412 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
413 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS", "GL_SGIS_multitexture" ],
414 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
416 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS", "GL_SGIS_multitexture" ],
417 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
418 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS", "GL_SGIS_multitexture" ],
419 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
421 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS", "GL_SGIS_multitexture" ],
422 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
423 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
424 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
426 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS", "GL_SGIS_multitexture" ],
427 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
428 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS", "GL_SGIS_multitexture" ],
429 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
431 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS", "GL_SGIS_multitexture" ],
432 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
433 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS", "GL_SGIS_multitexture" ],
434 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
437 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS", "GL_SGIS_multitexture" ],
438 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
439 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS", "GL_SGIS_multitexture" ],
440 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
443 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS", "GL_SGIS_multitexture" ],
444 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
445 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS", "GL_SGIS_multitexture" ],
446 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
449 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS", "GL_SGIS_multitexture" ],
450 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
451 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS", "GL_SGIS_multitexture" ],
452 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
455 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS", "GL_SGIS_multitexture" ],
456 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
457 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS", "GL_SGIS_multitexture" ],
458 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
462 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS", "GL_SGIS_multitexture" ],
463 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
464 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS", "GL_SGIS_multitexture" ],
465 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
469 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS", "GL_SGIS_multitexture" ],
470 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
471 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS", "GL_SGIS_multitexture" ],
472 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
476 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS", "GL_SGIS_multitexture" ],
477 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
478 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS", "GL_SGIS_multitexture" ],
479 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
483 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS", "GL_SGIS_multitexture" ],
484 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
485 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS", "GL_SGIS_multitexture" ],
486 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
488 [ "GLenum", "type" ],
489 [ "GLsizei", "stride" ],
490 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS", "GL_SGIS_multitexture" ],
491 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS", "GL_SGIS_multitexture" ],
492 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS", "GL_SGIS_multitexture" ],
493 "glDeleteObjectBufferATI" => [ "glDeleteObjectBufferATI", "void", [ [ "GLuint", "buffer" ] ], "glDeleteObjectBufferATI", "GL_ATI_vertex_array_object" ]
498 while (my $line = <REGISTRY
>) {
499 if ($line =~ /^\w*\(.*\)/) {
500 # Get the function name (NOTE: the 'gl' prefix needs to be added later)
501 my ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
502 # and the argument names
503 @arg_names = split /\s*,\s*/, $args;
507 # - category (the extension the function is part of)
508 # - the argument types
509 # - the category the function belongs
515 unless (defined($line)) {
517 } elsif ($line =~ /^\s*$/) {
518 if (($category eq "") || ($ret_type eq "")) {
519 die "Missing 'category' line in function $funcname.\n";
522 } elsif ($line =~ /\t*return\t*(\w*)/) {
523 ($ret_type) = ($line =~ /\t*return\s*(\w*)/);
524 $ret_type = $pseudo_to_opengl{$ret_type};
525 unless (defined($ret_type)) {
526 die "Unsupported return type in function $funcname\n";
528 } elsif ($line =~ /^\t*category/) {
529 ($category) = ($line =~ /^\t*category\s*([\w-]*)/);
530 } elsif ($line =~ /^\t*param/) {
531 my ($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
533 unless (defined($name)) {
535 die "Broken spec file line $line in function $funcname\n";
538 if ($ext =~ /array/) {
541 } elsif ($ext =~ /value/) {
542 # And this a 'normal' value
546 die "Unsupported type : $line in function $funcname\n";
548 # Get the 'real' type and append a '*' in case of a pointer
549 my $type = $pseudo_to_opengl{$base_type};
550 unless (defined($type)) {
552 die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
558 $arg_types{$name} = $type;
562 # Now, build the argument reference
564 for (my $i = 0; $i <= $#arg_names; $i++) {
565 unless (defined($arg_types{$arg_names[$i]})) {
566 print "@arg_names\n";
567 foreach (sort keys %arg_types) {
568 print "$_ => $arg_types{$_}\n";
570 die "Undefined type for $arg_names[$i] in function $funcname\n";
573 push @
$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
575 my $func_ref = [ "gl$funcname",
581 # Now, put in one or the other hash table
582 if ($norm_categories{$category}) {
583 $norm_functions{"gl$funcname"} = $func_ref;
585 $ext_functions{"gl$funcname"} = $func_ref;
591 # Clean up the input files
597 # Now, generate the output files. First, the spec file.
599 open(SPEC
, ">$spec_file");
601 foreach (sort keys %norm_functions) {
602 my $func_name = $norm_functions{$_}->[0];
603 print SPEC
"@ stdcall $func_name( ";
604 for (my $i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
605 my $type = $norm_functions{$_}->[2]->[$i]->[0];
608 } elsif (defined($arg_conv{$type})) {
609 print SPEC
"$@$arg_conv{$type}[0] ";
611 die "No conversion for GL type $type...\n";
614 print SPEC
") wine_$func_name\n";
617 print SPEC
"@ stub glGetLevelParameterfv
618 @ stub glGetLevelParameteriv
619 @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
620 @ stdcall wglCopyContext(long long long)
621 @ stdcall wglCreateContext(long) gdi32.wglCreateContext
622 @ stdcall wglCreateLayerContext(long long)
623 @ stdcall wglDeleteContext(long) gdi32.wglDeleteContext
624 @ stdcall wglDescribeLayerPlane(long long long long ptr)
625 @ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
626 @ stdcall wglGetCurrentContext() gdi32.wglGetCurrentContext
627 @ stdcall wglGetCurrentDC() gdi32.wglGetCurrentDC
628 @ stub wglGetDefaultProcAddress
629 @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
630 @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
631 @ stdcall wglGetProcAddress(str)
632 @ stdcall wglMakeCurrent(long long) gdi32.wglMakeCurrent
633 @ stdcall wglRealizeLayerPalette(long long long)
634 @ stdcall wglSetLayerPaletteEntries(long long long long ptr)
635 @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
636 @ stdcall wglShareLists(long long) gdi32.wglShareLists
637 @ stdcall wglSwapBuffers(long) gdi32.SwapBuffers
638 @ stdcall wglSwapLayerBuffers(long long)
639 @ stdcall wglUseFontBitmapsA(long long long long) gdi32.wglUseFontBitmapsA
640 @ stdcall wglUseFontBitmapsW(long long long long) gdi32.wglUseFontBitmapsW
641 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
642 @ stdcall wglUseFontOutlinesW(long long long long long long long ptr)
648 # After the spec file, the opengl_norm.c file
650 open(NORM
, ">$norm_file");
652 /* Auto-generated file... Do not edit ! */
654 #include \"config.h\"
655 #include \"opengl_ext.h\"
656 #include \"wine/debug.h\"
658 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
660 foreach (sort keys %norm_functions) {
661 my $string = GenerateThunk
($norm_functions{$_}, 1, "", $gen_thread_safe, "");
663 print NORM
"\n$string" if $string;
668 # Finally, more complex, the opengl_ext.c file
670 open(EXT
, ">$ext_file");
672 /* Auto-generated file... Do not edit ! */
674 #include \"config.h\"
675 #include \"opengl_ext.h\"
676 #include \"wine/debug.h\"
678 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
682 # The thunks themselves....
683 my $count = keys %ext_functions;
684 print EXT
"const int extension_registry_size = $count;\n";
685 print EXT
"void *extension_funcs[$count];\n";
686 print EXT
"\n/* The thunks themselves....*/";
688 foreach (sort keys %ext_functions) {
689 my $func_ref = $ext_functions{$_};
690 my $local_var = " " . ConvertType
($func_ref->[1]) . " (*$ext_prefix$func_ref->[0])( ";
691 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
692 my $type = ConvertType
($func_ref->[2]->[$i]->[0]);
693 $local_var .= "$type";
694 if ($i != $#{@{$func_ref->[2]}}) {
700 $local_var .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
701 $local_var .= ") = extension_funcs[$pos];\n";
703 print EXT
"\nstatic ", GenerateThunk
($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe, $local_var);
706 # Then the table giving the string <-> function correspondance */
707 print EXT
"\n\n/* The table giving the correspondance between names and functions */\n";
708 print EXT
"const OpenGL_extension extension_registry[$count] = {\n";
710 foreach (sort keys %ext_functions) {
711 my $func_ref = $ext_functions{$_};
712 if ($func_ref->[0] eq $func_ref->[3])
714 print EXT
" { \"$func_ref->[0]\", \"$func_ref->[4]\", (void *) wine_$func_ref->[0] }";
716 if ($i != $count-1) {