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 "glFinish";
219 return "" if $func_ref->[0] eq "glFlush";
221 # If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
222 # Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
224 $ret = "$ret/***********************************************************************\n";
225 $ret = "$ret * $func_ref->[0] (OPENGL32.\@)\n";
228 $ret = $ret . ConvertType
($func_ref->[1]) . " WINAPI wine_$func_ref->[0]( ";
229 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
230 ## Quick debug code :-)
231 ## print $func_ref->[2]->[$i]->[1] . "\n";
232 my $type = $func_ref->[2]->[$i]->[0];
233 my $name = ConvertVarName
($func_ref->[2]->[$i]->[1]);
234 $ret = $ret . ConvertType
($type) . " $name";
235 $call_arg = "$call_arg$name";
237 $trace_arg = "$trace_arg\%p";
239 $trace_arg = "$trace_arg$debug_conv{$type}";
241 if ($i != $#{@{$func_ref->[2]}}) {
243 $call_arg = "$call_arg, ";
244 $trace_arg = "$trace_arg, ";
247 $call_arg = "$call_arg ";
250 $ret .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
252 if ($func_ref->[1] ne "void") {
253 $ret = "$ret " . ConvertType
($func_ref->[1]) . " ret_value;\n";
257 $ret = "$ret TRACE(\"($trace_arg)\\n\"";
258 if ($trace_arg ne "") {
259 $ret = "$ret, $call_arg";
264 $ret = "$ret ENTER_GL();\n";
267 if ($func_ref->[1] ne "void") {
268 $ret = $ret . "ret_value = ";
270 $ret = "$ret$prefix$func_ref->[0]( $call_arg);\n";
272 $ret = "$ret LEAVE_GL();\n";
274 if ($func_ref->[1] ne "void") {
275 $ret = "$ret return ret_value;\n"
279 # Return this string....
284 # Extract and checks the number of arguments
289 die "Usage: $name0 OpenGL_registry_location OpenGL_version\n";
291 my $registry_path = shift @ARGV;
292 my $version = shift @ARGV;
293 if ($version eq "1.0") {
294 %norm_categories = %cat_1_0;
295 } elsif ($version eq "1.1") {
296 %norm_categories = %cat_1_1;
297 } elsif ($version eq "1.2") {
298 %norm_categories = %cat_1_2;
299 } elsif ($version eq "1.3") {
300 %norm_categories = %cat_1_3;
301 } elsif ($version eq "1.4") {
302 %norm_categories = %cat_1_4;
303 } elsif ($version eq "1.5") {
304 %norm_categories = %cat_1_5;
306 die "Incorrect OpenGL version.\n";
310 # Open the registry files
312 open(TYPES
, "$registry_path/gl.tm") || die "Could not open 'gl.tm'. Please check your path in the registry files.\n";
313 open(REGISTRY
, "$registry_path/gl.spec") || die "Could not open 'gl.spec'. Please check your path in the registry files.\n";
316 # First, create a mapping between the pseudo types used in the spec file
317 # and OpenGL types using the 'gl.tm' file.
319 my %pseudo_to_opengl = ();
320 while (my $line = <TYPES
>) {
321 if ($line !~ /\w*\#/) {
322 my ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
323 $pseudo_to_opengl{$pseudo} = $opengl;
326 # This is to override the 'void' -> '*' bogus conversion
327 $pseudo_to_opengl{"void"} = "void";
328 $pseudo_to_opengl{"Int64EXT"} = "INT64";
329 $pseudo_to_opengl{"UInt64EXT"} = "UINT64";
332 # Then, create the list of all OpenGL functions using the 'gl.spec'
333 # file. This will create two hash-tables, one with all the function
334 # whose category matches the one listed in '@norm_categories', the other
335 # with all other functions.
337 # An element of the hash table is a reference to an array with these
344 # - reference to an array giving the list of arguments (an empty array
345 # for a 'void' function).
347 # The list of arguments is itself an array of reference to arrays. Each
348 # of these arrays represents the argument type and the argument name.
352 # void glBitmap( GLsizei width, GLsizei height,
353 # GLfloat xorig, GLfloat yorig,
354 # GLfloat xmove, GLfloat ymove,
355 # const GLubyte *bitmap );
357 # Would give something like that :
361 # [ [ "GLsizei", "width" ],
362 # [ "GLsizei", "height" ],
363 # [ "GLfloat", "xorig" ],
364 # [ "GLfloat", "yorig" ],
365 # [ "GLfloat", "xmove" ],
366 # [ "GLfloat", "ymove" ],
367 # [ "GLubyte *", "bitmap"] ] ];
369 my %norm_functions = ();
372 # This stores various extensions NOT part of the GL extension registry but still
373 # implemented by most OpenGL libraries out there...
377 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion", "GL_KTX_buffer_region" ],
378 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
381 [ "GLsizei", "width" ],
382 [ "GLsizei", "height" ] ], "glReadBufferRegion", "GL_KTX_buffer_region" ],
383 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
386 [ "GLsizei", "width" ],
387 [ "GLsizei", "height" ],
388 [ "GLint", "xDest" ],
389 [ "GLint", "yDest" ] ], "glDrawBufferRegion", "GL_KTX_buffer_region" ],
390 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled", "GL_KTX_buffer_region" ],
391 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion", "GL_KTX_buffer_region" ],
392 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
394 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS", "GL_SGIS_multitexture" ],
395 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
396 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
397 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
398 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS", "GL_SGIS_multitexture" ],
399 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
400 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS", "GL_SGIS_multitexture" ],
401 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
402 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS", "GL_SGIS_multitexture" ],
403 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
404 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS", "GL_SGIS_multitexture" ],
405 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
406 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS", "GL_SGIS_multitexture" ],
407 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
408 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS", "GL_SGIS_multitexture" ],
409 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
410 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS", "GL_SGIS_multitexture" ],
411 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
412 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS", "GL_SGIS_multitexture" ],
413 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
415 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS", "GL_SGIS_multitexture" ],
416 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
417 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS", "GL_SGIS_multitexture" ],
418 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
420 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS", "GL_SGIS_multitexture" ],
421 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
422 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
423 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
425 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS", "GL_SGIS_multitexture" ],
426 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
427 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS", "GL_SGIS_multitexture" ],
428 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
430 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS", "GL_SGIS_multitexture" ],
431 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
432 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS", "GL_SGIS_multitexture" ],
433 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
436 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS", "GL_SGIS_multitexture" ],
437 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
438 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS", "GL_SGIS_multitexture" ],
439 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
442 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS", "GL_SGIS_multitexture" ],
443 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
444 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS", "GL_SGIS_multitexture" ],
445 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
448 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS", "GL_SGIS_multitexture" ],
449 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
450 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS", "GL_SGIS_multitexture" ],
451 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
454 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS", "GL_SGIS_multitexture" ],
455 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
456 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS", "GL_SGIS_multitexture" ],
457 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
461 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS", "GL_SGIS_multitexture" ],
462 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
463 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS", "GL_SGIS_multitexture" ],
464 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
468 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS", "GL_SGIS_multitexture" ],
469 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
470 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS", "GL_SGIS_multitexture" ],
471 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
475 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS", "GL_SGIS_multitexture" ],
476 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
477 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS", "GL_SGIS_multitexture" ],
478 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
482 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS", "GL_SGIS_multitexture" ],
483 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
484 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS", "GL_SGIS_multitexture" ],
485 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
487 [ "GLenum", "type" ],
488 [ "GLsizei", "stride" ],
489 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS", "GL_SGIS_multitexture" ],
490 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS", "GL_SGIS_multitexture" ],
491 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS", "GL_SGIS_multitexture" ],
492 "glDeleteObjectBufferATI" => [ "glDeleteObjectBufferATI", "void", [ [ "GLuint", "buffer" ] ], "glDeleteObjectBufferATI", "GL_ATI_vertex_array_object" ]
497 while (my $line = <REGISTRY
>) {
498 if ($line =~ /^\w*\(.*\)/) {
499 # Get the function name (NOTE: the 'gl' prefix needs to be added later)
500 my ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
501 # and the argument names
502 @arg_names = split /\s*,\s*/, $args;
506 # - category (the extension the function is part of)
507 # - the argument types
508 # - the category the function belongs
514 unless (defined($line)) {
516 } elsif ($line =~ /^\s*$/) {
517 if (($category eq "") || ($ret_type eq "")) {
518 die "Missing 'category' line in function $funcname.\n";
521 } elsif ($line =~ /\t*return\t*(\w*)/) {
522 ($ret_type) = ($line =~ /\t*return\s*(\w*)/);
523 $ret_type = $pseudo_to_opengl{$ret_type};
524 unless (defined($ret_type)) {
525 die "Unsupported return type in function $funcname\n";
527 } elsif ($line =~ /^\t*category/) {
528 ($category) = ($line =~ /^\t*category\s*([\w-]*)/);
529 } elsif ($line =~ /^\t*param/) {
530 my ($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
532 unless (defined($name)) {
534 die "Broken spec file line $line in function $funcname\n";
537 if ($ext =~ /array/) {
540 } elsif ($ext =~ /value/) {
541 # And this a 'normal' value
545 die "Unsupported type : $line in function $funcname\n";
547 # Get the 'real' type and append a '*' in case of a pointer
548 my $type = $pseudo_to_opengl{$base_type};
549 unless (defined($type)) {
551 die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
557 $arg_types{$name} = $type;
561 # Now, build the argument reference
563 for (my $i = 0; $i <= $#arg_names; $i++) {
564 unless (defined($arg_types{$arg_names[$i]})) {
565 print "@arg_names\n";
566 foreach (sort keys %arg_types) {
567 print "$_ => $arg_types{$_}\n";
569 die "Undefined type for $arg_names[$i] in function $funcname\n";
572 push @
$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
574 my $func_ref = [ "gl$funcname",
580 # Now, put in one or the other hash table
581 if ($norm_categories{$category}) {
582 $norm_functions{"gl$funcname"} = $func_ref;
584 $ext_functions{"gl$funcname"} = $func_ref;
590 # Clean up the input files
596 # Now, generate the output files. First, the spec file.
598 open(SPEC
, ">$spec_file");
600 foreach (sort keys %norm_functions) {
601 my $func_name = $norm_functions{$_}->[0];
602 print SPEC
"@ stdcall $func_name( ";
603 for (my $i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
604 my $type = $norm_functions{$_}->[2]->[$i]->[0];
607 } elsif (defined($arg_conv{$type})) {
608 print SPEC
"$@$arg_conv{$type}[0] ";
610 die "No conversion for GL type $type...\n";
613 print SPEC
") wine_$func_name\n";
616 print SPEC
"@ stub glGetLevelParameterfv
617 @ stub glGetLevelParameteriv
618 @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
619 @ stdcall wglCopyContext(long long long) gdi32.wglCopyContext
620 @ stdcall wglCreateContext(long) gdi32.wglCreateContext
621 @ stdcall wglCreateLayerContext(long long)
622 @ stdcall wglDeleteContext(long) gdi32.wglDeleteContext
623 @ stdcall wglDescribeLayerPlane(long long long long ptr)
624 @ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
625 @ stdcall wglGetCurrentContext() gdi32.wglGetCurrentContext
626 @ stdcall wglGetCurrentDC() gdi32.wglGetCurrentDC
627 @ stub wglGetDefaultProcAddress
628 @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
629 @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
630 @ stdcall wglGetProcAddress(str)
631 @ stdcall wglMakeCurrent(long long) gdi32.wglMakeCurrent
632 @ stdcall wglRealizeLayerPalette(long long long)
633 @ stdcall wglSetLayerPaletteEntries(long long long long ptr)
634 @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
635 @ stdcall wglShareLists(long long) gdi32.wglShareLists
636 @ stdcall wglSwapBuffers(long) gdi32.SwapBuffers
637 @ stdcall wglSwapLayerBuffers(long long)
638 @ stdcall wglUseFontBitmapsA(long long long long) gdi32.wglUseFontBitmapsA
639 @ stdcall wglUseFontBitmapsW(long long long long) gdi32.wglUseFontBitmapsW
640 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
641 @ stdcall wglUseFontOutlinesW(long long long long long long long ptr)
647 # After the spec file, the opengl_norm.c file
649 open(NORM
, ">$norm_file");
651 /* Auto-generated file... Do not edit ! */
653 #include \"config.h\"
654 #include \"opengl_ext.h\"
655 #include \"wine/debug.h\"
657 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
659 foreach (sort keys %norm_functions) {
660 my $string = GenerateThunk
($norm_functions{$_}, 1, "", $gen_thread_safe, "");
662 print NORM
"\n$string" if $string;
667 # Finally, more complex, the opengl_ext.c file
669 open(EXT
, ">$ext_file");
671 /* Auto-generated file... Do not edit ! */
673 #include \"config.h\"
674 #include \"opengl_ext.h\"
675 #include \"wine/debug.h\"
677 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
681 # The thunks themselves....
682 my $count = keys %ext_functions;
683 print EXT
"const int extension_registry_size = $count;\n";
684 print EXT
"void *extension_funcs[$count];\n";
685 print EXT
"\n/* The thunks themselves....*/";
687 foreach (sort keys %ext_functions) {
688 my $func_ref = $ext_functions{$_};
689 my $local_var = " " . ConvertType
($func_ref->[1]) . " (*$ext_prefix$func_ref->[0])( ";
690 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
691 my $type = ConvertType
($func_ref->[2]->[$i]->[0]);
692 $local_var .= "$type";
693 if ($i != $#{@{$func_ref->[2]}}) {
699 $local_var .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
700 $local_var .= ") = extension_funcs[$pos];\n";
702 print EXT
"\nstatic ", GenerateThunk
($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe, $local_var);
705 # Then the table giving the string <-> function correspondance */
706 print EXT
"\n\n/* The table giving the correspondance between names and functions */\n";
707 print EXT
"const OpenGL_extension extension_registry[$count] = {\n";
709 foreach (sort keys %ext_functions) {
710 my $func_ref = $ext_functions{$_};
711 if ($func_ref->[0] eq $func_ref->[3])
713 print EXT
" { \"$func_ref->[0]\", \"$func_ref->[4]\", (void *) wine_$func_ref->[0] }";
715 if ($i != $count-1) {