3 # This script is called thus :
5 # make_opengl path_to_spec_file opengl_version
7 # - path_to_spec_file is the path to the directory where the OpenGL
8 # spec files are located. These files are part of the OpenGL
9 # sample implementation CVS tree and are located in
10 # CVS_ROOT/projects/ogl-sample/main/doc/registry/specs.
11 # You can find them on the web at the following URL :
12 # http://oss.sgi.com/cgi-bin/cvsweb.cgi/projects/ogl-sample/main/doc/registry/specs/
14 # - opengl_version is the OpenGL version emulated by the library
15 # (can be 1.0 to 1.2).
17 # This script generates the three following files :
19 # - opengl32.spec : the spec file giving all the exported functions
20 # of the OpenGL32.DLL library. These functions are the one an
21 # application can directly link to (and are all the functions
22 # defined in the OpenGL core for the version defined by
25 # - opengl_norm.c : this file contains the thunks for all OpenGL
26 # functions that are defined in 'opengl32.spec'. The corresponding
27 # functions NEED to be defined in Linux's libGL or the library
28 # won't be able to be linked in.
30 # - opengl_ext.c : in this file are stored thunks for ALL possible
31 # OpenGL extensions (at least, all the extensions that are defined
32 # in the OpenGL extension registry). Contrary to 'opengl_norm.c',
33 # you do not need to have these extensions in your libGL to have
34 # OpenGL work (as they are resolved at run-time using
35 # glXGetProcAddressARB).
37 # Copyright 2000 Lionel Ulmer
39 # This library is free software; you can redistribute it and/or
40 # modify it under the terms of the GNU Lesser General Public
41 # License as published by the Free Software Foundation; either
42 # version 2.1 of the License, or (at your option) any later version.
44 # This library is distributed in the hope that it will be useful,
45 # but WITHOUT ANY WARRANTY; without even the implied warranty of
46 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47 # Lesser General Public License for more details.
49 # You should have received a copy of the GNU Lesser General Public
50 # License along with this library; if not, write to the Free Software
51 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57 $spec_file = "opengl32.spec";
58 $norm_file = "opengl_norm.c";
59 $ext_file = "opengl_ext.c";
61 # Set to 0 for removing the ENTER / LEAVE GL calls
63 # Prefix used for the local variables
64 $ext_prefix = "func_";
65 # If set to 1, generate TRACEs for each OpenGL function
69 # List of categories to put in the 'opengl_norm.c' file
71 %cat_1_0 = ( "display-list" => 1,
73 "drawing-control" => 1,
82 %cat_1_1 = ( %cat_1_0,
84 %cat_1_2 = ( %cat_1_1,
86 "ARB_multitexture" => 1 );
88 %norm_categories = ();
91 # This hash table gives the conversion between OpenGL types and what
92 # is used by the TRACE printfs
95 ("GLbitfield" => "%d",
110 "GLvoid" => "(void)",
111 "_GLfuncptr" => "%p");
114 # This hash table gives the conversion between OpenGL types and what
115 # is used in the .spec file
118 ("GLbitfield" => [ "long", 4 ],
119 "GLboolean" => [ "long", 4 ],
120 "GLbyte" => [ "long", 4 ],
121 "GLclampd" => [ "double", 8 ],
122 "GLclampf" => [ "long", 4 ],
123 "GLdouble" => [ "double", 8 ],
124 "GLenum" => [ "long", 4 ],
125 "GLfloat" => [ "long", 4 ],
126 "GLint" => [ "long", 4 ],
127 "GLshort" => [ "long", 4 ],
128 "GLsizei" => [ "long", 4 ],
129 "GLstring" => [ "str", 4 ],
130 "GLubyte" => [ "long", 4 ],
131 "GLuint" => [ "long", 4 ],
132 "GLushort" => [ "long", 4 ],
133 "GLvoid" => [ "void", 4 ],
134 "_GLfuncptr" => [ "ptr", 4 ]);
137 # This functions generates the thunk for a given function.
140 my ($func_ref, $comment, $prefix, $thread_safe) = @_;
142 my ($call_arg) = ("");
143 my ($trace_arg) = ("");
145 # If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
146 # Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
148 $ret = $ret . "/***********************************************************************\n";
149 $ret = $ret . " * " . $func_ref->[0] . " (OPENGL32.@)\n";
150 $ret = $ret . " */\n";
152 $ret = $ret . $func_ref->[1] . " WINAPI wine_" . $func_ref->[0] . "( ";
153 for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
154 $type = $func_ref->[2]->[$i]->[0];
155 $name = $func_ref->[2]->[$i]->[1];
156 $ret = $ret . "$type $name";
157 $call_arg = $call_arg . "$name";
159 $trace_arg = $trace_arg . "%p";
161 $trace_arg = $trace_arg . $debug_conv{$type};
163 if ($i != $#{@{$func_ref->[2]}}) {
165 $call_arg = $call_arg . ", ";
166 $trace_arg = $trace_arg . ", ";
169 $call_arg = $call_arg . " ";
172 $ret = $ret . ") {\n";
173 if ($func_ref->[1] ne "void") {
174 $ret = $ret . " " . $func_ref->[1] . " ret_value;\n";
177 $ret = $ret . " TRACE(\"(" . $trace_arg . ")\\n\"";
178 if ($trace_arg ne "") {
179 $ret = $ret . ", " . $call_arg;
181 $ret = $ret . ");\n";
184 $ret = $ret . " ENTER_GL();\n";
187 if ($func_ref->[1] ne "void") {
188 $ret = $ret . "ret_value = ";
190 $ret = $ret . $prefix . $func_ref->[0] . "( " . $call_arg . ");\n";
192 $ret = $ret . " LEAVE_GL();\n";
194 if ($func_ref->[1] ne "void") {
195 $ret = $ret . " return ret_value;\n"
199 # Return this string....
204 # Extract and checks the number of arguments
207 die "Usage : make_opengl OpenGL_registry_location OpenGL_version.\n";
209 $registry_path = shift @ARGV;
210 $version = shift @ARGV;
211 if ($version eq "1.0") {
212 %norm_categories = %cat_1_0;
213 } elsif ($version eq "1.1") {
214 %norm_categories = %cat_1_1;
215 } elsif ($version eq "1.2") {
216 %norm_categories = %cat_1_2;
218 die "OpenGL version incorrect. Should be one of '1.0', '1.1' or '1.2'.\n";
222 # Open the registry files
224 open(TYPES
, $registry_path . "/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
225 open(REGISTRY
, $registry_path . "/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
228 # First, create a mapping between the pseudo types used in the spec file
229 # and OpenGL types using the 'gl.tm' file.
231 %pseudo_to_opengl = ();
232 while ($line = <TYPES
>) {
233 ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
234 $pseudo_to_opengl{$pseudo} = $opengl;
236 # This is to override the 'void' -> '*' bogus conversion
237 $pseudo_to_opengl{"void"} = "void";
238 # This is a bug in the spec file...
239 $pseudo_to_opengl{"FfdTargetSGIX"} = "GLint";
240 $pseudo_to_opengl{"FfdMaskSGIX"} = "GLint";
241 $pseudo_to_opengl{"IglooFunctionSelectSGIX"} = "GLint";
242 $pseudo_to_opengl{"IglooParameterSGIX"} = "GLint";
245 # Then, create the list of all OpenGL functions using the 'gl.spec'
246 # file. This will create two hash-tables, one with all the function
247 # whose category matches the one listed in '@norm_categories', the other
248 # with all other functions.
250 # An element of the hash table is a reference to an array with these
257 # - reference to an array giving the list of arguments (an empty array
258 # for a 'void' function).
260 # The list of arguments is itself an array of reference to arrays. Each
261 # of these arrays represents the argument type and the argument name.
265 # void glBitmap( GLsizei width, GLsizei height,
266 # GLfloat xorig, GLfloat yorig,
267 # GLfloat xmove, GLfloat ymove,
268 # const GLubyte *bitmap );
270 # Would give something like that :
274 # [ [ "GLsizei", "width" ],
275 # [ "GLsizei", "height" ],
276 # [ "GLfloat", "xorig" ],
277 # [ "GLfloat", "yorig" ],
278 # [ "GLfloat", "xmove" ],
279 # [ "GLfloat", "ymove" ],
280 # [ "GLubyte *", "bitmap"] ] ];
282 %norm_functions = ();
285 # This stores various extensions NOT part of the GL extension registry but still
286 # implemented by most OpenGL libraries out there...
289 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion" ],
290 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
293 [ "GLsizei", "width" ],
294 [ "GLsizei", "height" ] ], "glReadBufferRegion" ],
295 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
298 [ "GLsizei", "width" ],
299 [ "GLsizei", "height" ],
300 [ "GLint", "xDest" ],
301 [ "GLint", "yDest" ] ], "glDrawBufferRegion" ],
302 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled" ],
303 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion" ],
304 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
306 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS" ],
307 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
308 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS" ],
309 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
310 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS" ],
311 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
312 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS" ],
313 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
314 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS" ],
315 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
316 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS" ],
317 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
318 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS" ],
319 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
320 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS" ],
321 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
322 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS" ],
323 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
324 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS" ],
325 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
327 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS" ],
328 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
329 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS" ],
330 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
332 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS" ],
333 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
334 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS" ],
335 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
337 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS" ],
338 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
339 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS" ],
340 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
342 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS" ],
343 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
344 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS" ],
345 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
348 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS" ],
349 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
350 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS" ],
351 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
354 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS" ],
355 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
356 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS" ],
357 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
360 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS" ],
361 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
362 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS" ],
363 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
366 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS" ],
367 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
368 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS" ],
369 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
373 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS" ],
374 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
375 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS" ],
376 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
380 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS" ],
381 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
382 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS" ],
383 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
387 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS" ],
388 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
389 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS" ],
390 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
394 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS" ],
395 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
396 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS" ],
397 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
399 [ "GLenum", "type" ],
400 [ "GLsizei", "stride" ],
401 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS" ],
402 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS" ],
403 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS" ],
404 "wglAllocateMemoryNV" => [ "wglAllocateMemoryNV", "void *", [ [ "GLsizei", "size" ],
405 [ "GLfloat", "readfreq" ],
406 [ "GLfloat", "writefreq"],
407 [ "GLfloat", "priority" ] ], "glXAllocateMemoryNV" ],
408 "wglFreeMemoryNV" => [ "wglFreeMemoryNV", "void", [ [ "GLvoid *", "pointer" ] ], "glXFreeMemoryNV" ]
412 while ($line = <REGISTRY
>) {
413 if ($line =~ /^\w*\(.*\)/) {
414 # Get the function name (NOTE: the 'gl' prefix needs to be added later)
415 ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
416 # and the argument names
417 @arg_names = split /\s*,\s*/, $args;
421 # - the argument types
422 # - the category the function belongs
428 unless (defined($line)) {
430 } elsif ($line =~ /^\s*$/) {
431 if (($category eq "") || ($ret_type eq "")) {
432 die "Missing 'category' line in function $funcname.\n";
435 } elsif ($line =~ /\t*return\t*(\w*)/) {
436 ($ret_type) = ($line =~ /\t*return\s*(\w*)/);
437 $ret_type = $pseudo_to_opengl{$ret_type};
438 unless (defined($ret_type)) {
439 die "Unsupported return type in function $funcname\n";
441 } elsif ($line =~ /^\t*category/) {
442 ($category) = ($line =~ /^\t*category\s*([\w-]*)/);
443 } elsif ($line =~ /^\t*param/) {
444 ($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
446 unless (defined($name)) {
448 die "Broken spec file line $line in function $funcname\n";
451 if ($ext =~ /array/) {
454 } elsif ($ext =~ /value/) {
455 # And this a 'normal' value
459 die "Unsupported type : $line in function $funcname\n";
461 # Get the 'real' type and append a '*' in case of a pointer
462 $type = $pseudo_to_opengl{$base_type};
463 unless (defined($type)) {
465 die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
471 $arg_types{$name} = $type;
475 # Now, build the argument reference
477 for ($i = 0; $i <= $#arg_names; $i++) {
478 unless (defined($arg_types{$arg_names[$i]})) {
479 print "@arg_names\n";
480 foreach (sort keys %arg_types) {
481 print "$_ => $arg_types{$_}\n";
483 die "Undefined type for $arg_names[$i] in function $funcname\n";
486 push @
$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
488 $func_ref = [ "gl" . $funcname,
493 # Now, put in one or the other hash table
494 if ($norm_categories{$category}) {
495 $norm_functions{"gl" . $funcname} = $func_ref;
497 $ext_functions{"gl" . $funcname} = $func_ref;
503 # Clean up the input files
509 # Now, generate the output files. First, the spec file.
511 open(SPEC
, ">" . $spec_file);
513 print SPEC
"@ stdcall wglCreateContext(long) wglCreateContext
514 @ stdcall wglCreateLayerContext(long long) wglCreateLayerContext
515 @ stdcall wglCopyContext(long long long) wglCopyContext
516 @ stdcall wglDeleteContext(long) wglDeleteContext
517 @ stdcall wglDescribeLayerPlane(long long long long ptr) wglDescribeLayerPlane
518 @ stdcall wglGetCurrentContext() wglGetCurrentContext
519 @ stdcall wglGetCurrentDC() wglGetCurrentDC
520 @ stdcall wglGetExtensionsStringEXT() wglGetExtensionsStringEXT
521 @ stdcall wglGetLayerPaletteEntries(long long long long ptr) wglGetLayerPaletteEntries
522 @ stdcall wglGetProcAddress(str) wglGetProcAddress
523 @ stdcall wglMakeCurrent(long long) wglMakeCurrent
524 @ stdcall wglRealizeLayerPalette(long long long) wglRealizeLayerPalette
525 @ stdcall wglSetLayerPaletteEntries(long long long long ptr) wglSetLayerPaletteEntries
526 @ stdcall wglShareLists(long long) wglShareLists
527 @ stdcall wglSwapLayerBuffers(long long) wglSwapLayerBuffers
528 @ stdcall wglUseFontBitmapsA(long long long long) wglUseFontBitmapsA
529 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr) wglUseFontOutlinesA
530 @ stub glGetLevelParameterfv
531 @ stub glGetLevelParameteriv
532 @ stub wglUseFontBitmapsW
533 @ stub wglUseFontOutlinesW
534 @ stub wglGetDefaultProcAddress
535 @ forward wglChoosePixelFormat GDI32.ChoosePixelFormat
536 @ forward wglDescribePixelFormat GDI32.DescribePixelFormat
537 @ forward wglGetPixelFormat GDI32.GetPixelFormat
538 @ forward wglSetPixelFormat GDI32.SetPixelFormat
539 @ forward wglSwapBuffers GDI32.SwapBuffers
542 foreach (sort keys %norm_functions) {
543 $func_name = $norm_functions{$_}->[0];
544 print SPEC
"@ stdcall $func_name( ";
545 for ($i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
546 $type = $norm_functions{$_}->[2]->[$i]->[0];
549 } elsif (defined($arg_conv{$type})) {
550 print SPEC
"$@$arg_conv{$type}[0] ";
552 die "No convertion for GL type $type...\n";
555 print SPEC
") wine_$func_name\n";
560 # After the spec file, the opengl_norm.c file
562 open(NORM
, ">" . $norm_file);
564 /* Auto-generated file... Do not edit ! */
566 #include \"config.h\"
567 #include \"opengl_ext.h\"
568 #include \"wine/debug.h\"
570 typedef const GLubyte * GLstring;
572 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
575 foreach (sort keys %norm_functions) {
576 $string = GenerateThunk
($norm_functions{$_}, 1, "", $gen_thread_safe);
578 print NORM
"$string\n";
583 # Finally, more complex, the opengl_ext.c file
585 open(EXT
, ">" . $ext_file);
587 /* Auto-generated file... Do not edit ! */
589 #include \"config.h\"
590 #include \"opengl_ext.h\"
591 #include \"wine/debug.h\"
593 typedef const GLubyte * GLstring;
595 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
599 # First, generate the function pointers
600 foreach (sort keys %ext_functions) {
601 $func_ref = $ext_functions{$_};
602 print EXT
$func_ref->[1] . " (*" . $ext_prefix . $func_ref->[0] . ")( ";
603 for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
604 $type = $func_ref->[2]->[$i]->[0];
606 if ($i != $#{@{$func_ref->[2]}}) {
612 print EXT
") = (void *) 0xdeadbeef;\n";
615 # Then, the function prototypes
616 print EXT
"\n\n/* The function prototypes */\n";
617 foreach (sort keys %ext_functions) {
618 $func_ref = $ext_functions{$_};
619 print EXT
$func_ref->[1] . " WINAPI " . "wine_" . $func_ref->[0] . "( ";
620 for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
621 $type = $func_ref->[2]->[$i]->[0];
623 if ($i != $#{@{$func_ref->[2]}}) {
632 # Then the table giving the string <-> function correspondance */
633 print EXT
"\n\n/* The table giving the correspondance between names and functions */\n";
634 @tmp = keys %ext_functions;
635 print EXT
"int extension_registry_size = " . ($#tmp + 1) . ";\n";
636 print EXT
"OpenGL_extension extension_registry[" . ($#tmp + 1) . "] = {\n";
638 foreach (sort keys %ext_functions) {
639 $func_ref = $ext_functions{$_};
640 print EXT
" { \"" . $func_ref->[0] . "\", \"" . $func_ref->[3] . "\", (void *) wine_" . $func_ref->[0] . ", (void **) (&" . $ext_prefix . $func_ref->[0] . ") }";
649 # And, finally, the thunks themselves....
650 print EXT
"\n/* The thunks themselves....*/\n";
651 foreach (sort keys %ext_functions) {
652 $string = GenerateThunk
($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe);
654 print EXT
"$string\n";