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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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",
171 "GLhalfNV" => "unsigned short" );
173 foreach my $org (reverse sort keys %hash) {
174 if ($type =~ /$org/) {
175 my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
176 return "$before$hash{$org}$after";
183 # Used to convert some variable names
185 sub ConvertVarName($)
189 my %hash = ( "near" => "nearParam",
190 "far" => "farParam" );
192 foreach my $org (keys %hash) {
193 if ($type =~ /$org/) {
194 my ($before, $after) = ($type =~ /^(.*)$org(.*)$/);
195 return "$before$hash{$org}$after";
202 # This functions generates the thunk for a given function.
204 sub GenerateThunk($$$$)
206 my ($func_ref, $comment, $prefix, $thread_safe) = @_;
210 my $wine_func_ref_name = "";
212 # If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
213 # Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
215 $ret = "$ret/***********************************************************************\n";
216 $ret = "$ret * $func_ref->[0] (OPENGL32.\@)\n";
219 $ret = $ret . ConvertType($func_ref->[1]) . " WINAPI wine_$func_ref->[0]( ";
220 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
221 ## Quick debug code :-)
222 ## print $func_ref->[2]->[$i]->[1] . "\n";
223 my $type = $func_ref->[2]->[$i]->[0];
224 my $name = ConvertVarName($func_ref->[2]->[$i]->[1]);
225 $ret = $ret . ConvertType($type) . " $name";
226 $call_arg = "$call_arg$name";
228 $trace_arg = "$trace_arg\%p";
230 $trace_arg = "$trace_arg$debug_conv{$type}";
232 if ($i != $#{@{$func_ref->[2]}}) {
234 $call_arg = "$call_arg, ";
235 $trace_arg = "$trace_arg, ";
238 $call_arg = "$call_arg ";
241 $ret .= 'void ' if ($#{@{$func_ref->[2]}} < 0);
243 if ($func_ref->[1] ne "void") {
244 $ret = "$ret " . ConvertType($func_ref->[1]) . " ret_value;\n";
247 $ret = "$ret TRACE(\"($trace_arg)\\n\"";
248 if ($trace_arg ne "") {
249 $ret = "$ret, $call_arg";
254 $ret = "$ret ENTER_GL();\n";
257 if ($func_ref->[1] ne "void") {
258 $ret = $ret . "ret_value = ";
260 $wine_func_ref_name = $func_ref->[0];
261 if ( $func_ref->[0] eq "glGetString" ) {
262 $wine_func_ref_name = "internal_glGetString";
264 $ret = "$ret$prefix$wine_func_ref_name( $call_arg);\n";
266 $ret = "$ret LEAVE_GL();\n";
268 if ($func_ref->[1] ne "void") {
269 $ret = "$ret return ret_value;\n"
273 # Return this string....
278 # Extract and checks the number of arguments
283 die "Usage: $name0 OpenGL_registry_location OpenGL_version\n";
285 my $registry_path = shift @ARGV;
286 my $version = shift @ARGV;
287 if ($version eq "1.0") {
288 %norm_categories = %cat_1_0;
289 } elsif ($version eq "1.1") {
290 %norm_categories = %cat_1_1;
291 } elsif ($version eq "1.2") {
292 %norm_categories = %cat_1_2;
293 } elsif ($version eq "1.3") {
294 %norm_categories = %cat_1_3;
295 } elsif ($version eq "1.4") {
296 %norm_categories = %cat_1_4;
297 } elsif ($version eq "1.5") {
298 %norm_categories = %cat_1_5;
300 die "Incorrect OpenGL version.\n";
304 # Open the registry files
306 open(TYPES, "$registry_path/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
307 open(REGISTRY, "$registry_path/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
310 # First, create a mapping between the pseudo types used in the spec file
311 # and OpenGL types using the 'gl.tm' file.
313 my %pseudo_to_opengl = ();
314 while (my $line = <TYPES>) {
315 if ($line !~ /\w*\#/) {
316 my ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
317 $pseudo_to_opengl{$pseudo} = $opengl;
320 # This is to override the 'void' -> '*' bogus conversion
321 $pseudo_to_opengl{"void"} = "void";
322 # This is a bug in the spec file...
323 $pseudo_to_opengl{"FfdTargetSGIX"} = "GLint";
324 $pseudo_to_opengl{"FfdMaskSGIX"} = "GLint";
325 $pseudo_to_opengl{"IglooFunctionSelectSGIX"} = "GLint";
326 $pseudo_to_opengl{"IglooParameterSGIX"} = "GLint";
329 # Then, create the list of all OpenGL functions using the 'gl.spec'
330 # file. This will create two hash-tables, one with all the function
331 # whose category matches the one listed in '@norm_categories', the other
332 # with all other functions.
334 # An element of the hash table is a reference to an array with these
341 # - reference to an array giving the list of arguments (an empty array
342 # for a 'void' function).
344 # The list of arguments is itself an array of reference to arrays. Each
345 # of these arrays represents the argument type and the argument name.
349 # void glBitmap( GLsizei width, GLsizei height,
350 # GLfloat xorig, GLfloat yorig,
351 # GLfloat xmove, GLfloat ymove,
352 # const GLubyte *bitmap );
354 # Would give something like that :
358 # [ [ "GLsizei", "width" ],
359 # [ "GLsizei", "height" ],
360 # [ "GLfloat", "xorig" ],
361 # [ "GLfloat", "yorig" ],
362 # [ "GLfloat", "xmove" ],
363 # [ "GLfloat", "ymove" ],
364 # [ "GLubyte *", "bitmap"] ] ];
366 my %norm_functions = ();
369 # This stores various extensions NOT part of the GL extension registry but still
370 # implemented by most OpenGL libraries out there...
374 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion" ],
375 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
378 [ "GLsizei", "width" ],
379 [ "GLsizei", "height" ] ], "glReadBufferRegion" ],
380 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
383 [ "GLsizei", "width" ],
384 [ "GLsizei", "height" ],
385 [ "GLint", "xDest" ],
386 [ "GLint", "yDest" ] ], "glDrawBufferRegion" ],
387 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled" ],
388 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion" ],
389 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
391 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS" ],
392 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
393 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS" ],
394 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
395 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS" ],
396 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
397 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS" ],
398 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
399 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS" ],
400 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
401 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS" ],
402 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
403 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS" ],
404 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
405 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS" ],
406 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
407 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS" ],
408 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
409 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS" ],
410 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
412 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS" ],
413 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
414 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS" ],
415 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
417 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS" ],
418 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
419 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS" ],
420 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
422 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS" ],
423 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
424 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS" ],
425 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
427 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS" ],
428 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
429 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS" ],
430 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
433 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS" ],
434 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
435 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS" ],
436 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
439 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS" ],
440 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
441 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS" ],
442 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
445 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS" ],
446 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
447 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS" ],
448 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
451 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS" ],
452 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
453 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS" ],
454 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
458 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS" ],
459 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
460 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS" ],
461 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
465 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS" ],
466 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
467 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS" ],
468 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
472 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS" ],
473 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
474 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS" ],
475 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
479 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS" ],
480 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
481 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS" ],
482 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
484 [ "GLenum", "type" ],
485 [ "GLsizei", "stride" ],
486 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS" ],
487 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS" ],
488 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS" ],
489 "wglAllocateMemoryNV" => [ "wglAllocateMemoryNV", "void *", [ [ "GLsizei", "size" ],
490 [ "GLfloat", "readfreq" ],
491 [ "GLfloat", "writefreq"],
492 [ "GLfloat", "priority" ] ], "glXAllocateMemoryNV" ],
493 "wglFreeMemoryNV" => [ "wglFreeMemoryNV", "void", [ [ "GLvoid *", "pointer" ] ], "glXFreeMemoryNV" ],
494 "glDeleteObjectBufferATI" => [ "glDeleteObjectBufferATI", "void", [ [ "GLuint", "buffer" ] ], "glDeleteObjectBufferATI" ]
499 while (my $line = <REGISTRY>) {
500 if ($line =~ /^\w*\(.*\)/) {
501 # Get the function name (NOTE: the 'gl' prefix needs to be added later)
502 my ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
503 # and the argument names
504 @arg_names = split /\s*,\s*/, $args;
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",
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 print SPEC "@ stdcall wglCreateContext(long)
601 @ stdcall wglCreateLayerContext(long long)
602 @ stdcall wglCopyContext(long long long)
603 @ stdcall wglDeleteContext(long)
604 @ stdcall wglDescribeLayerPlane(long long long long ptr)
605 @ stdcall wglGetCurrentContext()
606 @ stdcall wglGetCurrentDC()
607 @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
608 @ stdcall wglGetProcAddress(str)
609 @ stdcall wglMakeCurrent(long long)
610 @ stdcall wglRealizeLayerPalette(long long long)
611 @ stdcall wglSetLayerPaletteEntries(long long long long ptr)
612 @ stdcall wglShareLists(long long)
613 @ stdcall wglSwapLayerBuffers(long long)
614 @ stdcall wglUseFontBitmapsA(long long long long)
615 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
616 @ stub glGetLevelParameterfv
617 @ stub glGetLevelParameteriv
618 @ stdcall wglUseFontBitmapsW(long long long long)
619 @ stub wglUseFontOutlinesW
620 @ stub wglGetDefaultProcAddress
621 @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
622 @ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
623 @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
624 @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
625 @ stdcall wglSwapBuffers(long) gdi32.SwapBuffers
628 foreach (sort keys %norm_functions) {
629 my $func_name = $norm_functions{$_}->[0];
630 print SPEC "@ stdcall $func_name( ";
631 for (my $i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
632 my $type = $norm_functions{$_}->[2]->[$i]->[0];
635 } elsif (defined($arg_conv{$type})) {
636 print SPEC "$@$arg_conv{$type}[0] ";
638 die "No conversion for GL type $type...\n";
641 print SPEC ") wine_$func_name\n";
646 # After the spec file, the opengl_norm.c file
648 open(NORM, ">$norm_file");
650 /* Auto-generated file... Do not edit ! */
652 #include \"config.h\"
653 #include \"opengl_ext.h\"
654 #include \"wine/debug.h\"
656 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
658 foreach (sort keys %norm_functions) {
659 my $string = GenerateThunk($norm_functions{$_}, 1, "", $gen_thread_safe);
661 print NORM "\n$string";
666 # Finally, more complex, the opengl_ext.c file
668 open(EXT, ">$ext_file");
670 /* Auto-generated file... Do not edit ! */
672 #include \"config.h\"
673 #include \"opengl_ext.h\"
674 #include \"wine/debug.h\"
676 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
680 # First, generate the function pointers
681 foreach (sort keys %ext_functions) {
682 my $func_ref = $ext_functions{$_};
683 print EXT ConvertType($func_ref->[1]), " (*$ext_prefix$func_ref->[0])( ";
684 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
685 my $type = ConvertType($func_ref->[2]->[$i]->[0]);
687 if ($i != $#{@{$func_ref->[2]}}) {
693 print EXT 'void ' if ($#{@{$func_ref->[2]}} < 0);
694 print EXT ") = (void *) 0xdeadbeef;\n";
697 # Then, the function prototypes
698 print EXT "\n\n/* The function prototypes */\n";
699 foreach (sort keys %ext_functions) {
700 my $func_ref = $ext_functions{$_};
701 print EXT ConvertType($func_ref->[1]), " WINAPI wine_$func_ref->[0]( ";
702 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
703 my $type = ConvertType($func_ref->[2]->[$i]->[0]);
705 if ($i != $#{@{$func_ref->[2]}}) {
711 print EXT 'void ' if ($#{@{$func_ref->[2]}} < 0);
715 # Then the table giving the string <-> function correspondance */
716 print EXT "\n\n/* The table giving the correspondance between names and functions */\n";
717 my @tmp = keys %ext_functions;
718 print EXT "int extension_registry_size = ", ($#tmp + 1), ";\n";
719 print EXT "OpenGL_extension extension_registry[", ($#tmp + 1), "] = {\n";
721 foreach (sort keys %ext_functions) {
722 my $func_ref = $ext_functions{$_};
723 print EXT " { \"$func_ref->[0]\", \"$func_ref->[3]\", (void *) wine_$func_ref->[0], (void **) (&$ext_prefix$func_ref->[0]) }";
732 # And, finally, the thunks themselves....
733 print EXT "\n/* The thunks themselves....*/";
734 foreach (sort keys %ext_functions) {
735 my $string = GenerateThunk($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe);
737 print EXT "\n$string";