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 part of the OpenGL
10 # sample implementation CVS tree and are located in
11 # CVS_ROOT/projects/ogl-sample/main/doc/registry/specs.
12 # You can find them on the web at the following URL :
13 # http://oss.sgi.com/cgi-bin/cvsweb.cgi/projects/ogl-sample/main/doc/registry/specs/
14 # You will need gl.tm and gl.spec.
16 # - opengl_version is the OpenGL version emulated by the library
17 # (can be 1.0 to 1.5).
19 # This script generates the three following files :
21 # - opengl32.spec : the spec file giving all the exported functions
22 # of the OpenGL32.DLL library. These functions are the one an
23 # application can directly link to (and are all the functions
24 # defined in the OpenGL core for the version defined by
27 # - opengl_norm.c : this file contains the thunks for all OpenGL
28 # functions that are defined in 'opengl32.spec'. The corresponding
29 # functions NEED to be defined in Linux's libGL or the library
30 # won't be able to be linked in.
32 # - opengl_ext.c : in this file are stored thunks for ALL possible
33 # OpenGL extensions (at least, all the extensions that are defined
34 # in the OpenGL extension registry). Contrary to 'opengl_norm.c',
35 # you do not need to have these extensions in your libGL to have
36 # OpenGL work (as they are resolved at run-time using
37 # glXGetProcAddressARB).
39 # Copyright 2000 Lionel Ulmer
41 # This library is free software; you can redistribute it and/or
42 # modify it under the terms of the GNU Lesser General Public
43 # License as published by the Free Software Foundation; either
44 # version 2.1 of the License, or (at your option) any later version.
46 # This library is distributed in the hope that it will be useful,
47 # but WITHOUT ANY WARRANTY; without even the implied warranty of
48 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
49 # Lesser General Public License for more details.
51 # You should have received a copy of the GNU Lesser General Public
52 # License along with this library; if not, write to the Free Software
53 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
59 my $spec_file = "opengl32.spec";
60 my $norm_file = "opengl_norm.c";
61 my $ext_file = "opengl_ext.c";
63 # Set to 0 for removing the ENTER / LEAVE GL calls
64 my $gen_thread_safe = 1;
65 # Prefix used for the local variables
66 my $ext_prefix = "func_";
67 # If set to 1, generate TRACEs for each OpenGL function
71 # List of categories to put in the 'opengl_norm.c' file
73 my %cat_1_0 = ( "display-list" => 1,
75 "drawing-control" => 1,
84 my %cat_1_1 = ( %cat_1_0,
86 my %cat_1_2 = ( %cat_1_1,
88 my %cat_1_3 = ( %cat_1_2,
90 my %cat_1_4 = ( %cat_1_3,
92 my %cat_1_5 = ( %cat_1_4,
95 my %norm_categories = ();
98 # This hash table gives the conversion between OpenGL types and what
99 # is used by the TRACE printfs
102 ("GLbitfield" => "%d",
118 "GLintptrARB" => "%d",
119 "GLsizeiptrARB" => "%d",
121 "GLsizeiptr" => "%d",
122 "GLhandleARB" => "%d",
124 "GLvoid" => "(void)",
125 "_GLfuncptr" => "%p");
128 # This hash table gives the conversion between OpenGL types and what
129 # is used in the .spec file
132 ("GLbitfield" => [ "long", 4 ],
133 "GLboolean" => [ "long", 4 ],
134 "GLbyte" => [ "long", 4 ],
135 "GLclampd" => [ "double", 8 ],
136 "GLclampf" => [ "long", 4 ],
137 "GLdouble" => [ "double", 8 ],
138 "GLenum" => [ "long", 4 ],
139 "GLfloat" => [ "long", 4 ],
140 "GLint" => [ "long", 4 ],
141 "GLshort" => [ "long", 4 ],
142 "GLsizei" => [ "long", 4 ],
143 "GLstring" => [ "str", 4 ],
144 "GLubyte" => [ "long", 4 ],
145 "GLuint" => [ "long", 4 ],
146 "GLushort" => [ "long", 4 ],
147 "GLhalfNV" => [ "long", 4 ],
148 "GLintptrARB" => [ "long", 4 ],
149 "GLsizeiptrARB" => [ "long", 4 ],
150 "GLhandleARB" => [ "long", 4 ],
151 "GLcharARB" => [ "long", 4 ],
152 "GLintptr" => [ "long", 4 ],
153 "GLsizeiptr" => [ "long", 4 ],
154 "GLvoid" => [ "void", 4 ],
155 "_GLfuncptr" => [ "ptr", 4 ]);
158 # Used to convert some types
164 my %hash = ( "GLstring" => "const GLubyte *",
165 "GLintptrARB" => "ptrdiff_t",
166 "GLsizeiptrARB" => "ptrdiff_t",
167 "GLintptr" => "ptrdiff_t",
168 "GLsizeiptr" => "ptrdiff_t",
169 "GLhandleARB" => "unsigned int",
170 "GLcharARB" => "char",
172 "GLhalfNV" => "unsigned short" );
174 foreach my $org (reverse sort keys %hash) {
175 if ($type =~ /$org/) {
176 my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
177 return "$before$hash{$org}$after";
184 # Used to convert some variable names
186 sub ConvertVarName($)
190 my %hash = ( "near" => "nearParam",
191 "far" => "farParam" );
193 foreach my $org (keys %hash) {
194 if ($type =~ /$org/) {
195 my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
196 return "$before$hash{$org}$after";
203 # This functions generates the thunk for a given function.
205 sub GenerateThunk($$$$$)
207 my ($func_ref, $comment, $prefix, $thread_safe, $local_var) = @_;
212 return "" if $func_ref->[0] eq "glGetString";
213 return "" if $func_ref->[0] eq "glGetIntegerv";
214 return "" if $func_ref->[0] eq "glEnable";
215 return "" if $func_ref->[0] eq "glIsEnabled";
216 return "" if $func_ref->[0] eq "glDisable";
217 return "" if $func_ref->[0] eq "glScissor";
218 return "" if $func_ref->[0] eq "glViewport";
220 # If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
221 # Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
223 $ret = "$ret/***********************************************************************\n";
224 $ret = "$ret * $func_ref->[0] (OPENGL32.\@)\n";
227 $ret = $ret . ConvertType($func_ref->[1]) . " WINAPI wine_$func_ref->[0]( ";
228 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
229 ## Quick debug code :-)
230 ## print $func_ref->[2]->[$i]->[1] . "\n";
231 my $type = $func_ref->[2]->[$i]->[0];
232 my $name = ConvertVarName($func_ref->[2]->[$i]->[1]);
233 $ret = $ret . ConvertType($type) . " $name";
234 $call_arg = "$call_arg$name";
236 $trace_arg = "$trace_arg\%p";
238 $trace_arg = "$trace_arg$debug_conv{$type}";
240 if ($i != $#{@{$func_ref->[2]}}) {
242 $call_arg = "$call_arg, ";
243 $trace_arg = "$trace_arg, ";
246 $call_arg = "$call_arg ";
249 $ret .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
251 if ($func_ref->[1] ne "void") {
252 $ret = "$ret " . ConvertType($func_ref->[1]) . " ret_value;\n";
256 $ret = "$ret TRACE(\"($trace_arg)\\n\"";
257 if ($trace_arg ne "") {
258 $ret = "$ret, $call_arg";
263 $ret = "$ret ENTER_GL();\n";
266 if ($func_ref->[1] ne "void") {
267 $ret = $ret . "ret_value = ";
269 $ret = "$ret$prefix$func_ref->[0]( $call_arg);\n";
271 $ret = "$ret LEAVE_GL();\n";
273 if ($func_ref->[1] ne "void") {
274 $ret = "$ret return ret_value;\n"
278 # Return this string....
283 # Extract and checks the number of arguments
288 die "Usage: $name0 OpenGL_registry_location OpenGL_version\n";
290 my $registry_path = shift @ARGV;
291 my $version = shift @ARGV;
292 if ($version eq "1.0") {
293 %norm_categories = %cat_1_0;
294 } elsif ($version eq "1.1") {
295 %norm_categories = %cat_1_1;
296 } elsif ($version eq "1.2") {
297 %norm_categories = %cat_1_2;
298 } elsif ($version eq "1.3") {
299 %norm_categories = %cat_1_3;
300 } elsif ($version eq "1.4") {
301 %norm_categories = %cat_1_4;
302 } elsif ($version eq "1.5") {
303 %norm_categories = %cat_1_5;
305 die "Incorrect OpenGL version.\n";
309 # Open the registry files
311 open(TYPES, "$registry_path/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
312 open(REGISTRY, "$registry_path/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
315 # First, create a mapping between the pseudo types used in the spec file
316 # and OpenGL types using the 'gl.tm' file.
318 my %pseudo_to_opengl = ();
319 while (my $line = <TYPES>) {
320 if ($line !~ /\w*\#/) {
321 my ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
322 $pseudo_to_opengl{$pseudo} = $opengl;
325 # This is to override the 'void' -> '*' bogus conversion
326 $pseudo_to_opengl{"void"} = "void";
327 $pseudo_to_opengl{"Int64EXT"} = "INT64";
328 $pseudo_to_opengl{"UInt64EXT"} = "UINT64";
329 # This is a bug in the spec file...
330 $pseudo_to_opengl{"FfdTargetSGIX"} = "GLint";
331 $pseudo_to_opengl{"FfdMaskSGIX"} = "GLint";
332 $pseudo_to_opengl{"IglooFunctionSelectSGIX"} = "GLint";
333 $pseudo_to_opengl{"IglooParameterSGIX"} = "GLint";
336 # Then, create the list of all OpenGL functions using the 'gl.spec'
337 # file. This will create two hash-tables, one with all the function
338 # whose category matches the one listed in '@norm_categories', the other
339 # with all other functions.
341 # An element of the hash table is a reference to an array with these
348 # - reference to an array giving the list of arguments (an empty array
349 # for a 'void' function).
351 # The list of arguments is itself an array of reference to arrays. Each
352 # of these arrays represents the argument type and the argument name.
356 # void glBitmap( GLsizei width, GLsizei height,
357 # GLfloat xorig, GLfloat yorig,
358 # GLfloat xmove, GLfloat ymove,
359 # const GLubyte *bitmap );
361 # Would give something like that :
365 # [ [ "GLsizei", "width" ],
366 # [ "GLsizei", "height" ],
367 # [ "GLfloat", "xorig" ],
368 # [ "GLfloat", "yorig" ],
369 # [ "GLfloat", "xmove" ],
370 # [ "GLfloat", "ymove" ],
371 # [ "GLubyte *", "bitmap"] ] ];
373 my %norm_functions = ();
376 # This stores various extensions NOT part of the GL extension registry but still
377 # implemented by most OpenGL libraries out there...
381 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion", "GL_KTX_buffer_region" ],
382 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
385 [ "GLsizei", "width" ],
386 [ "GLsizei", "height" ] ], "glReadBufferRegion", "GL_KTX_buffer_region" ],
387 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
390 [ "GLsizei", "width" ],
391 [ "GLsizei", "height" ],
392 [ "GLint", "xDest" ],
393 [ "GLint", "yDest" ] ], "glDrawBufferRegion", "GL_KTX_buffer_region" ],
394 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled", "GL_KTX_buffer_region" ],
395 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion", "GL_KTX_buffer_region" ],
396 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
398 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS", "GL_SGIS_multitexture" ],
399 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
400 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
401 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
402 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS", "GL_SGIS_multitexture" ],
403 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
404 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS", "GL_SGIS_multitexture" ],
405 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
406 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS", "GL_SGIS_multitexture" ],
407 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
408 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS", "GL_SGIS_multitexture" ],
409 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
410 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS", "GL_SGIS_multitexture" ],
411 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
412 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS", "GL_SGIS_multitexture" ],
413 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
414 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS", "GL_SGIS_multitexture" ],
415 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
416 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS", "GL_SGIS_multitexture" ],
417 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
419 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS", "GL_SGIS_multitexture" ],
420 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
421 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS", "GL_SGIS_multitexture" ],
422 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
424 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS", "GL_SGIS_multitexture" ],
425 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
426 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS", "GL_SGIS_multitexture" ],
427 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
429 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS", "GL_SGIS_multitexture" ],
430 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
431 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS", "GL_SGIS_multitexture" ],
432 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
434 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS", "GL_SGIS_multitexture" ],
435 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
436 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS", "GL_SGIS_multitexture" ],
437 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
440 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS", "GL_SGIS_multitexture" ],
441 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
442 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS", "GL_SGIS_multitexture" ],
443 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
446 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS", "GL_SGIS_multitexture" ],
447 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
448 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS", "GL_SGIS_multitexture" ],
449 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
452 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS", "GL_SGIS_multitexture" ],
453 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
454 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS", "GL_SGIS_multitexture" ],
455 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
458 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS", "GL_SGIS_multitexture" ],
459 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
460 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS", "GL_SGIS_multitexture" ],
461 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
465 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS", "GL_SGIS_multitexture" ],
466 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
467 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS", "GL_SGIS_multitexture" ],
468 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
472 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS", "GL_SGIS_multitexture" ],
473 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
474 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS", "GL_SGIS_multitexture" ],
475 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
479 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS", "GL_SGIS_multitexture" ],
480 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
481 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS", "GL_SGIS_multitexture" ],
482 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
486 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS", "GL_SGIS_multitexture" ],
487 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
488 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS", "GL_SGIS_multitexture" ],
489 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
491 [ "GLenum", "type" ],
492 [ "GLsizei", "stride" ],
493 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS", "GL_SGIS_multitexture" ],
494 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS", "GL_SGIS_multitexture" ],
495 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS", "GL_SGIS_multitexture" ],
496 "glDeleteObjectBufferATI" => [ "glDeleteObjectBufferATI", "void", [ [ "GLuint", "buffer" ] ], "glDeleteObjectBufferATI", "GL_ATI_vertex_array_object" ]
501 while (my $line = <REGISTRY>) {
502 if ($line =~ /^\w*\(.*\)/) {
503 # Get the function name (NOTE: the 'gl' prefix needs to be added later)
504 my ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
505 # and the argument names
506 @arg_names = split /\s*,\s*/, $args;
510 # - category (the extension the function is part of)
511 # - the argument types
512 # - the category the function belongs
518 unless (defined($line)) {
520 } elsif ($line =~ /^\s*$/) {
521 if (($category eq "") || ($ret_type eq "")) {
522 die "Missing 'category' line in function $funcname.\n";
525 } elsif ($line =~ /\t*return\t*(\w*)/) {
526 ($ret_type) = ($line =~ /\t*return\s*(\w*)/);
527 $ret_type = $pseudo_to_opengl{$ret_type};
528 unless (defined($ret_type)) {
529 die "Unsupported return type in function $funcname\n";
531 } elsif ($line =~ /^\t*category/) {
532 ($category) = ($line =~ /^\t*category\s*([\w-]*)/);
533 } elsif ($line =~ /^\t*param/) {
534 my ($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
536 unless (defined($name)) {
538 die "Broken spec file line $line in function $funcname\n";
541 if ($ext =~ /array/) {
544 } elsif ($ext =~ /value/) {
545 # And this a 'normal' value
549 die "Unsupported type : $line in function $funcname\n";
551 # Get the 'real' type and append a '*' in case of a pointer
552 my $type = $pseudo_to_opengl{$base_type};
553 unless (defined($type)) {
555 die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
561 $arg_types{$name} = $type;
565 # Now, build the argument reference
567 for (my $i = 0; $i <= $#arg_names; $i++) {
568 unless (defined($arg_types{$arg_names[$i]})) {
569 print "@arg_names\n";
570 foreach (sort keys %arg_types) {
571 print "$_ => $arg_types{$_}\n";
573 die "Undefined type for $arg_names[$i] in function $funcname\n";
576 push @$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
578 my $func_ref = [ "gl$funcname",
584 # Now, put in one or the other hash table
585 if ($norm_categories{$category}) {
586 $norm_functions{"gl$funcname"} = $func_ref;
588 $ext_functions{"gl$funcname"} = $func_ref;
594 # Clean up the input files
600 # Now, generate the output files. First, the spec file.
602 open(SPEC, ">$spec_file");
604 foreach (sort keys %norm_functions) {
605 my $func_name = $norm_functions{$_}->[0];
606 print SPEC "@ stdcall $func_name( ";
607 for (my $i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
608 my $type = $norm_functions{$_}->[2]->[$i]->[0];
611 } elsif (defined($arg_conv{$type})) {
612 print SPEC "$@$arg_conv{$type}[0] ";
614 die "No conversion for GL type $type...\n";
617 print SPEC ") wine_$func_name\n";
620 print SPEC "@ stub glGetLevelParameterfv
621 @ stub glGetLevelParameteriv
622 @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
623 @ stdcall wglCopyContext(long long long)
624 @ stdcall wglCreateContext(long) gdi32.wglCreateContext
625 @ stdcall wglCreateLayerContext(long long)
626 @ stdcall wglDeleteContext(long) gdi32.wglDeleteContext
627 @ stdcall wglDescribeLayerPlane(long long long long ptr)
628 @ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
629 @ stdcall wglGetCurrentContext() gdi32.wglGetCurrentContext
630 @ stdcall wglGetCurrentDC() gdi32.wglGetCurrentDC
631 @ stub wglGetDefaultProcAddress
632 @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
633 @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
634 @ stdcall wglGetProcAddress(str)
635 @ stdcall wglMakeCurrent(long long) gdi32.wglMakeCurrent
636 @ stdcall wglRealizeLayerPalette(long long long)
637 @ stdcall wglSetLayerPaletteEntries(long long long long ptr)
638 @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
639 @ stdcall wglShareLists(long long) gdi32.wglShareLists
640 @ stdcall wglSwapBuffers(long) gdi32.SwapBuffers
641 @ stdcall wglSwapLayerBuffers(long long)
642 @ stdcall wglUseFontBitmapsA(long long long long) gdi32.wglUseFontBitmapsA
643 @ stdcall wglUseFontBitmapsW(long long long long) gdi32.wglUseFontBitmapsW
644 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
645 @ stdcall wglUseFontOutlinesW(long long long long long long long ptr)
651 # After the spec file, the opengl_norm.c file
653 open(NORM, ">$norm_file");
655 /* Auto-generated file... Do not edit ! */
657 #include \"config.h\"
658 #include \"opengl_ext.h\"
659 #include \"wine/debug.h\"
661 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
663 foreach (sort keys %norm_functions) {
664 my $string = GenerateThunk($norm_functions{$_}, 1, "", $gen_thread_safe, "");
666 print NORM "\n$string" if $string;
671 # Finally, more complex, the opengl_ext.c file
673 open(EXT, ">$ext_file");
675 /* Auto-generated file... Do not edit ! */
677 #include \"config.h\"
678 #include \"opengl_ext.h\"
679 #include \"wine/debug.h\"
681 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
685 # The thunks themselves....
686 my $count = keys %ext_functions;
687 print EXT "const int extension_registry_size = $count;\n";
688 print EXT "void *extension_funcs[$count];\n";
689 print EXT "\n/* The thunks themselves....*/";
691 foreach (sort keys %ext_functions) {
692 my $func_ref = $ext_functions{$_};
693 my $local_var = " " . ConvertType($func_ref->[1]) . " (*$ext_prefix$func_ref->[0])( ";
694 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
695 my $type = ConvertType($func_ref->[2]->[$i]->[0]);
696 $local_var .= "$type";
697 if ($i != $#{@{$func_ref->[2]}}) {
703 $local_var .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
704 $local_var .= ") = extension_funcs[$pos];\n";
706 print EXT "\nstatic ", GenerateThunk($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe, $local_var);
709 # Then the table giving the string <-> function correspondance */
710 print EXT "\n\n/* The table giving the correspondance between names and functions */\n";
711 print EXT "const OpenGL_extension extension_registry[$count] = {\n";
713 foreach (sort keys %ext_functions) {
714 my $func_ref = $ext_functions{$_};
715 if ($func_ref->[0] eq $func_ref->[3])
717 print EXT " { \"$func_ref->[0]\", \"$func_ref->[4]\", (void *) wine_$func_ref->[0] }";
719 if ($i != $count-1) {