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 ";
242 if ($func_ref->[1] ne "void") {
243 $ret = "$ret " . ConvertType($func_ref->[1]) . " ret_value;\n";
246 $ret = "$ret TRACE(\"($trace_arg)\\n\"";
247 if ($trace_arg ne "") {
248 $ret = "$ret, $call_arg";
253 $ret = "$ret ENTER_GL();\n";
256 if ($func_ref->[1] ne "void") {
257 $ret = $ret . "ret_value = ";
259 $wine_func_ref_name = $func_ref->[0];
260 if ( $func_ref->[0] eq "glGetString" ) {
261 $wine_func_ref_name = "internal_glGetString";
263 $ret = "$ret$prefix$wine_func_ref_name( $call_arg);\n";
265 $ret = "$ret LEAVE_GL();\n";
267 if ($func_ref->[1] ne "void") {
268 $ret = "$ret return ret_value;\n"
272 # Return this string....
277 # Extract and checks the number of arguments
282 die "Usage: $name0 OpenGL_registry_location OpenGL_version\n";
284 my $registry_path = shift @ARGV;
285 my $version = shift @ARGV;
286 if ($version eq "1.0") {
287 %norm_categories = %cat_1_0;
288 } elsif ($version eq "1.1") {
289 %norm_categories = %cat_1_1;
290 } elsif ($version eq "1.2") {
291 %norm_categories = %cat_1_2;
292 } elsif ($version eq "1.3") {
293 %norm_categories = %cat_1_3;
294 } elsif ($version eq "1.4") {
295 %norm_categories = %cat_1_4;
296 } elsif ($version eq "1.5") {
297 %norm_categories = %cat_1_5;
299 die "Incorrect OpenGL version.\n";
303 # Open the registry files
305 open(TYPES, "$registry_path/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
306 open(REGISTRY, "$registry_path/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
309 # First, create a mapping between the pseudo types used in the spec file
310 # and OpenGL types using the 'gl.tm' file.
312 my %pseudo_to_opengl = ();
313 while (my $line = <TYPES>) {
314 if ($line !~ /\w*\#/) {
315 my ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
316 $pseudo_to_opengl{$pseudo} = $opengl;
319 # This is to override the 'void' -> '*' bogus conversion
320 $pseudo_to_opengl{"void"} = "void";
321 # This is a bug in the spec file...
322 $pseudo_to_opengl{"FfdTargetSGIX"} = "GLint";
323 $pseudo_to_opengl{"FfdMaskSGIX"} = "GLint";
324 $pseudo_to_opengl{"IglooFunctionSelectSGIX"} = "GLint";
325 $pseudo_to_opengl{"IglooParameterSGIX"} = "GLint";
328 # Then, create the list of all OpenGL functions using the 'gl.spec'
329 # file. This will create two hash-tables, one with all the function
330 # whose category matches the one listed in '@norm_categories', the other
331 # with all other functions.
333 # An element of the hash table is a reference to an array with these
340 # - reference to an array giving the list of arguments (an empty array
341 # for a 'void' function).
343 # The list of arguments is itself an array of reference to arrays. Each
344 # of these arrays represents the argument type and the argument name.
348 # void glBitmap( GLsizei width, GLsizei height,
349 # GLfloat xorig, GLfloat yorig,
350 # GLfloat xmove, GLfloat ymove,
351 # const GLubyte *bitmap );
353 # Would give something like that :
357 # [ [ "GLsizei", "width" ],
358 # [ "GLsizei", "height" ],
359 # [ "GLfloat", "xorig" ],
360 # [ "GLfloat", "yorig" ],
361 # [ "GLfloat", "xmove" ],
362 # [ "GLfloat", "ymove" ],
363 # [ "GLubyte *", "bitmap"] ] ];
365 my %norm_functions = ();
368 # This stores various extensions NOT part of the GL extension registry but still
369 # implemented by most OpenGL libraries out there...
373 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion" ],
374 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
377 [ "GLsizei", "width" ],
378 [ "GLsizei", "height" ] ], "glReadBufferRegion" ],
379 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
382 [ "GLsizei", "width" ],
383 [ "GLsizei", "height" ],
384 [ "GLint", "xDest" ],
385 [ "GLint", "yDest" ] ], "glDrawBufferRegion" ],
386 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled" ],
387 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion" ],
388 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
390 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS" ],
391 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
392 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS" ],
393 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
394 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS" ],
395 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
396 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS" ],
397 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
398 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS" ],
399 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
400 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS" ],
401 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
402 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS" ],
403 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
404 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS" ],
405 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
406 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS" ],
407 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
408 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS" ],
409 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
411 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS" ],
412 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
413 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS" ],
414 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
416 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS" ],
417 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
418 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS" ],
419 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
421 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS" ],
422 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
423 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS" ],
424 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
426 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS" ],
427 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
428 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS" ],
429 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
432 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS" ],
433 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
434 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS" ],
435 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
438 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS" ],
439 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
440 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS" ],
441 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
444 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS" ],
445 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
446 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS" ],
447 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
450 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS" ],
451 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
452 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS" ],
453 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
457 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS" ],
458 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
459 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS" ],
460 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
464 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS" ],
465 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
466 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS" ],
467 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
471 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS" ],
472 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
473 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS" ],
474 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
478 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS" ],
479 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
480 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS" ],
481 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
483 [ "GLenum", "type" ],
484 [ "GLsizei", "stride" ],
485 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS" ],
486 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS" ],
487 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS" ],
488 "wglAllocateMemoryNV" => [ "wglAllocateMemoryNV", "void *", [ [ "GLsizei", "size" ],
489 [ "GLfloat", "readfreq" ],
490 [ "GLfloat", "writefreq"],
491 [ "GLfloat", "priority" ] ], "glXAllocateMemoryNV" ],
492 "wglFreeMemoryNV" => [ "wglFreeMemoryNV", "void", [ [ "GLvoid *", "pointer" ] ], "glXFreeMemoryNV" ],
493 "glDeleteObjectBufferATI" => [ "glDeleteObjectBufferATI", "void", [ [ "GLuint", "buffer" ] ], "glDeleteObjectBufferATI" ]
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 # - 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",
579 # Now, put in one or the other hash table
580 if ($norm_categories{$category}) {
581 $norm_functions{"gl$funcname"} = $func_ref;
583 $ext_functions{"gl$funcname"} = $func_ref;
589 # Clean up the input files
595 # Now, generate the output files. First, the spec file.
597 open(SPEC, ">$spec_file");
599 print SPEC "@ stdcall wglCreateContext(long)
600 @ stdcall wglCreateLayerContext(long long)
601 @ stdcall wglCopyContext(long long long)
602 @ stdcall wglDeleteContext(long)
603 @ stdcall wglDescribeLayerPlane(long long long long ptr)
604 @ stdcall wglGetCurrentContext()
605 @ stdcall wglGetCurrentDC()
606 @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
607 @ stdcall wglGetProcAddress(str)
608 @ stdcall wglMakeCurrent(long long)
609 @ stdcall wglRealizeLayerPalette(long long long)
610 @ stdcall wglSetLayerPaletteEntries(long long long long ptr)
611 @ stdcall wglShareLists(long long)
612 @ stdcall wglSwapLayerBuffers(long long)
613 @ stdcall wglUseFontBitmapsA(long long long long)
614 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
615 @ stub glGetLevelParameterfv
616 @ stub glGetLevelParameteriv
617 @ stdcall wglUseFontBitmapsW(long long long long)
618 @ stub wglUseFontOutlinesW
619 @ stub wglGetDefaultProcAddress
620 @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
621 @ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
622 @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
623 @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
624 @ stdcall wglSwapBuffers(long) gdi32.SwapBuffers
627 foreach (sort keys %norm_functions) {
628 my $func_name = $norm_functions{$_}->[0];
629 print SPEC "@ stdcall $func_name( ";
630 for (my $i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
631 my $type = $norm_functions{$_}->[2]->[$i]->[0];
634 } elsif (defined($arg_conv{$type})) {
635 print SPEC "$@$arg_conv{$type}[0] ";
637 die "No convertion for GL type $type...\n";
640 print SPEC ") wine_$func_name\n";
645 # After the spec file, the opengl_norm.c file
647 open(NORM, ">$norm_file");
649 /* Auto-generated file... Do not edit ! */
651 #include \"config.h\"
652 #include \"opengl_ext.h\"
653 #include \"wine/debug.h\"
655 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
657 foreach (sort keys %norm_functions) {
658 my $string = GenerateThunk($norm_functions{$_}, 1, "", $gen_thread_safe);
660 print NORM "\n$string";
665 # Finally, more complex, the opengl_ext.c file
667 open(EXT, ">$ext_file");
669 /* Auto-generated file... Do not edit ! */
671 #include \"config.h\"
672 #include \"opengl_ext.h\"
673 #include \"wine/debug.h\"
675 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
679 # First, generate the function pointers
680 foreach (sort keys %ext_functions) {
681 my $func_ref = $ext_functions{$_};
682 print EXT ConvertType($func_ref->[1]), " (*$ext_prefix$func_ref->[0])( ";
683 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
684 my $type = ConvertType($func_ref->[2]->[$i]->[0]);
686 if ($i != $#{@{$func_ref->[2]}}) {
692 print EXT ") = (void *) 0xdeadbeef;\n";
695 # Then, the function prototypes
696 print EXT "\n\n/* The function prototypes */\n";
697 foreach (sort keys %ext_functions) {
698 my $func_ref = $ext_functions{$_};
699 print EXT ConvertType($func_ref->[1]), " WINAPI wine_$func_ref->[0]( ";
700 for (my $i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
701 my $type = ConvertType($func_ref->[2]->[$i]->[0]);
703 if ($i != $#{@{$func_ref->[2]}}) {
712 # Then the table giving the string <-> function correspondance */
713 print EXT "\n\n/* The table giving the correspondance between names and functions */\n";
714 my @tmp = keys %ext_functions;
715 print EXT "int extension_registry_size = ", ($#tmp + 1), ";\n";
716 print EXT "OpenGL_extension extension_registry[", ($#tmp + 1), "] = {\n";
718 foreach (sort keys %ext_functions) {
719 my $func_ref = $ext_functions{$_};
720 print EXT " { \"$func_ref->[0]\", \"$func_ref->[3]\", (void *) wine_$func_ref->[0], (void **) (&$ext_prefix$func_ref->[0]) }";
729 # And, finally, the thunks themselves....
730 print EXT "\n/* The thunks themselves....*/";
731 foreach (sort keys %ext_functions) {
732 my $string = GenerateThunk($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe);
734 print EXT "\n$string";