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",
111 "GLintptrARB" => "%d",
112 "GLsizeiptrARB" => "%d",
113 "GLvoid" => "(void)",
114 "_GLfuncptr" => "%p");
117 # This hash table gives the conversion between OpenGL types and what
118 # is used in the .spec file
121 ("GLbitfield" => [ "long", 4 ],
122 "GLboolean" => [ "long", 4 ],
123 "GLbyte" => [ "long", 4 ],
124 "GLclampd" => [ "double", 8 ],
125 "GLclampf" => [ "long", 4 ],
126 "GLdouble" => [ "double", 8 ],
127 "GLenum" => [ "long", 4 ],
128 "GLfloat" => [ "long", 4 ],
129 "GLint" => [ "long", 4 ],
130 "GLshort" => [ "long", 4 ],
131 "GLsizei" => [ "long", 4 ],
132 "GLstring" => [ "str", 4 ],
133 "GLubyte" => [ "long", 4 ],
134 "GLuint" => [ "long", 4 ],
135 "GLushort" => [ "long", 4 ],
136 "GLhalfNV" => [ "long", 4 ],
137 "GLintptrARB" => [ "long", 4 ],
138 "GLsizeiptrARB" => [ "long", 4 ],
139 "GLvoid" => [ "void", 4 ],
140 "_GLfuncptr" => [ "ptr", 4 ]);
143 # This functions generates the thunk for a given function.
146 my ($func_ref, $comment, $prefix, $thread_safe) = @_;
148 my ($call_arg) = ("");
149 my ($trace_arg) = ("");
151 # If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
152 # Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
154 $ret = $ret . "/***********************************************************************\n";
155 $ret = $ret . " * " . $func_ref->[0] . " (OPENGL32.@)\n";
156 $ret = $ret . " */\n";
158 $ret = $ret . $func_ref->[1] . " WINAPI wine_" . $func_ref->[0] . "( ";
159 for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
160 $type = $func_ref->[2]->[$i]->[0];
161 $name = $func_ref->[2]->[$i]->[1];
162 $ret = $ret . "$type $name";
163 $call_arg = $call_arg . "$name";
165 $trace_arg = $trace_arg . "%p";
167 $trace_arg = $trace_arg . $debug_conv{$type};
169 if ($i != $#{@{$func_ref->[2]}}) {
171 $call_arg = $call_arg . ", ";
172 $trace_arg = $trace_arg . ", ";
175 $call_arg = $call_arg . " ";
178 $ret = $ret . ") {\n";
179 if ($func_ref->[1] ne "void") {
180 $ret = $ret . " " . $func_ref->[1] . " ret_value;\n";
183 $ret = $ret . " TRACE(\"(" . $trace_arg . ")\\n\"";
184 if ($trace_arg ne "") {
185 $ret = $ret . ", " . $call_arg;
187 $ret = $ret . ");\n";
190 $ret = $ret . " ENTER_GL();\n";
193 if ($func_ref->[1] ne "void") {
194 $ret = $ret . "ret_value = ";
196 $ret = $ret . $prefix . $func_ref->[0] . "( " . $call_arg . ");\n";
198 $ret = $ret . " LEAVE_GL();\n";
200 if ($func_ref->[1] ne "void") {
201 $ret = $ret . " return ret_value;\n"
205 # Return this string....
210 # Extract and checks the number of arguments
213 die "Usage : make_opengl OpenGL_registry_location OpenGL_version.\n";
215 $registry_path = shift @ARGV;
216 $version = shift @ARGV;
217 if ($version eq "1.0") {
218 %norm_categories = %cat_1_0;
219 } elsif ($version eq "1.1") {
220 %norm_categories = %cat_1_1;
221 } elsif ($version eq "1.2") {
222 %norm_categories = %cat_1_2;
224 die "OpenGL version incorrect. Should be one of '1.0', '1.1' or '1.2'.\n";
228 # Open the registry files
230 open(TYPES, $registry_path . "/gl.tm") || die "Could not open 'gl.tm'. Please check your path the the registry files.\n";
231 open(REGISTRY, $registry_path . "/gl.spec") || die "Could not open 'gl.spec'. Please check your path the the registry files.\n";
234 # First, create a mapping between the pseudo types used in the spec file
235 # and OpenGL types using the 'gl.tm' file.
237 %pseudo_to_opengl = ();
238 while ($line = <TYPES>) {
239 if ($line !~ /\w*\#/) {
240 ($pseudo, $opengl) = ($line =~ /(\w*),\*,\*,\s*(.*),\*,\*/);
241 $pseudo_to_opengl{$pseudo} = $opengl;
244 # This is to override the 'void' -> '*' bogus conversion
245 $pseudo_to_opengl{"void"} = "void";
246 # This is a bug in the spec file...
247 $pseudo_to_opengl{"FfdTargetSGIX"} = "GLint";
248 $pseudo_to_opengl{"FfdMaskSGIX"} = "GLint";
249 $pseudo_to_opengl{"IglooFunctionSelectSGIX"} = "GLint";
250 $pseudo_to_opengl{"IglooParameterSGIX"} = "GLint";
253 # Then, create the list of all OpenGL functions using the 'gl.spec'
254 # file. This will create two hash-tables, one with all the function
255 # whose category matches the one listed in '@norm_categories', the other
256 # with all other functions.
258 # An element of the hash table is a reference to an array with these
265 # - reference to an array giving the list of arguments (an empty array
266 # for a 'void' function).
268 # The list of arguments is itself an array of reference to arrays. Each
269 # of these arrays represents the argument type and the argument name.
273 # void glBitmap( GLsizei width, GLsizei height,
274 # GLfloat xorig, GLfloat yorig,
275 # GLfloat xmove, GLfloat ymove,
276 # const GLubyte *bitmap );
278 # Would give something like that :
282 # [ [ "GLsizei", "width" ],
283 # [ "GLsizei", "height" ],
284 # [ "GLfloat", "xorig" ],
285 # [ "GLfloat", "yorig" ],
286 # [ "GLfloat", "xmove" ],
287 # [ "GLfloat", "ymove" ],
288 # [ "GLubyte *", "bitmap"] ] ];
290 %norm_functions = ();
293 # This stores various extensions NOT part of the GL extension registry but still
294 # implemented by most OpenGL libraries out there...
297 ( "glDeleteBufferRegion" => [ "glDeleteBufferRegion", "void", [ [ "GLenum", "region" ] ], "glDeleteBufferRegion" ],
298 "glReadBufferRegion" => [ "glReadBufferRegion", "void", [ [ "GLenum", "region" ],
301 [ "GLsizei", "width" ],
302 [ "GLsizei", "height" ] ], "glReadBufferRegion" ],
303 "glDrawBufferRegion" => [ "glDrawBufferRegion", "void", [ [ "GLenum", "region" ],
306 [ "GLsizei", "width" ],
307 [ "GLsizei", "height" ],
308 [ "GLint", "xDest" ],
309 [ "GLint", "yDest" ] ], "glDrawBufferRegion" ],
310 "glBufferRegionEnabled" => [ "glBufferRegionEnabled", "GLuint", [ ], "glBufferRegionEnabled" ],
311 "glNewBufferRegion" => [ "glNewBufferRegion", "GLuint", [ [ "GLenum", "type" ] ], "glNewBufferRegion" ],
312 "glMTexCoord2fSGIS" => [ "glMTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
314 [ "GLfloat", "t" ] ], "glMTexCoord2fSGIS" ],
315 "glMTexCoord2fvSGIS" => [ "glMTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
316 [ "GLfloat *", "v" ] ], "glMTexCoord2fvSGIS" ],
317 "glMultiTexCoord1dSGIS" => [ "glMultiTexCoord1dSGIS", "void", [ [ "GLenum", "target" ],
318 [ "GLdouble", "s" ] ], "glMultiTexCoord1dSGIS" ],
319 "glMultiTexCoord1dvSGIS" => [ "glMultiTexCoord1dvSGIS", "void", [ [ "GLenum", "target" ],
320 [ "GLdouble *", "v" ] ], "glMultiTexCoord1dvSGIS" ],
321 "glMultiTexCoord1fSGIS" => [ "glMultiTexCoord1fSGIS", "void", [ [ "GLenum", "target" ],
322 [ "GLfloat", "s" ] ], "glMultiTexCoord1fSGIS" ],
323 "glMultiTexCoord1fvSGIS" => [ "glMultiTexCoord1fvSGIS", "void", [ [ "GLenum", "target" ],
324 [ "const GLfloat *", "v" ] ], "glMultiTexCoord1fvSGIS" ],
325 "glMultiTexCoord1iSGIS" => [ "glMultiTexCoord1iSGIS", "void", [ [ "GLenum", "target" ],
326 [ "GLint", "s" ] ], "glMultiTexCoord1iSGIS" ],
327 "glMultiTexCoord1ivSGIS" => [ "glMultiTexCoord1ivSGIS", "void", [ [ "GLenum", "target" ],
328 [ "GLint *", "v" ] ], "glMultiTexCoord1ivSGIS" ],
329 "glMultiTexCoord1sSGIS" => [ "glMultiTexCoord1sSGIS", "void", [ [ "GLenum", "target" ],
330 [ "GLshort", "s" ] ], "glMultiTexCoord1sSGIS" ],
331 "glMultiTexCoord1svSGIS" => [ "glMultiTexCoord1svSGIS", "void", [ [ "GLenum", "target" ],
332 [ "GLshort *", "v" ] ], "glMultiTexCoord1svSGIS" ],
333 "glMultiTexCoord2dSGIS" => [ "glMultiTexCoord2dSGIS", "void", [ [ "GLenum", "target" ],
335 [ "GLdouble", "t" ] ], "glMultiTexCoord2dSGIS" ],
336 "glMultiTexCoord2dvSGIS" => [ "glMultiTexCoord2dvSGIS", "void", [ [ "GLenum", "target" ],
337 [ "GLdouble *", "v" ] ], "glMultiTexCoord2dvSGIS" ],
338 "glMultiTexCoord2fSGIS" => [ "glMultiTexCoord2fSGIS", "void", [ [ "GLenum", "target" ],
340 [ "GLfloat", "t" ] ], "glMultiTexCoord2fSGIS" ],
341 "glMultiTexCoord2fvSGIS" => [ "glMultiTexCoord2fvSGIS", "void", [ [ "GLenum", "target" ],
342 [ "GLfloat *", "v" ] ], "glMultiTexCoord2fvSGIS" ],
343 "glMultiTexCoord2iSGIS" => [ "glMultiTexCoord2iSGIS", "void", [ [ "GLenum", "target" ],
345 [ "GLint", "t" ] ], "glMultiTexCoord2iSGIS" ],
346 "glMultiTexCoord2ivSGIS" => [ "glMultiTexCoord2ivSGIS", "void", [ [ "GLenum", "target" ],
347 [ "GLint *", "v" ] ], "glMultiTexCoord2ivSGIS" ],
348 "glMultiTexCoord2sSGIS" => [ "glMultiTexCoord2sSGIS", "void", [ [ "GLenum", "target" ],
350 [ "GLshort", "t" ] ], "glMultiTexCoord2sSGIS" ],
351 "glMultiTexCoord2svSGIS" => [ "glMultiTexCoord2svSGIS", "void", [ [ "GLenum", "target" ],
352 [ "GLshort *", "v" ] ], "glMultiTexCoord2svSGIS" ],
353 "glMultiTexCoord3dSGIS" => [ "glMultiTexCoord3dSGIS", "void", [ [ "GLenum", "target" ],
356 [ "GLdouble", "r" ] ], "glMultiTexCoord3dSGIS" ],
357 "glMultiTexCoord3dvSGIS" => [ "glMultiTexCoord3dvSGIS", "void", [ [ "GLenum", "target" ],
358 [ "GLdouble *", "v" ] ], "glMultiTexCoord3dvSGIS" ],
359 "glMultiTexCoord3fSGIS" => [ "glMultiTexCoord3fSGIS", "void", [ [ "GLenum", "target" ],
362 [ "GLfloat", "r" ] ], "glMultiTexCoord3fSGIS" ],
363 "glMultiTexCoord3fvSGIS" => [ "glMultiTexCoord3fvSGIS", "void", [ [ "GLenum", "target" ],
364 [ "GLfloat *", "v" ] ], "glMultiTexCoord3fvSGIS" ],
365 "glMultiTexCoord3iSGIS" => [ "glMultiTexCoord3iSGIS", "void", [ [ "GLenum", "target" ],
368 [ "GLint", "r" ] ], "glMultiTexCoord3iSGIS" ],
369 "glMultiTexCoord3ivSGIS" => [ "glMultiTexCoord3ivSGIS", "void", [ [ "GLenum", "target" ],
370 [ "GLint *", "v" ] ], "glMultiTexCoord3ivSGIS" ],
371 "glMultiTexCoord3sSGIS" => [ "glMultiTexCoord3sSGIS", "void", [ [ "GLenum", "target" ],
374 [ "GLshort", "r" ] ], "glMultiTexCoord3sSGIS" ],
375 "glMultiTexCoord3svSGIS" => [ "glMultiTexCoord3svSGIS", "void", [ [ "GLenum", "target" ],
376 [ "GLshort *", "v" ] ], "glMultiTexCoord3svSGIS" ],
377 "glMultiTexCoord4dSGIS" => [ "glMultiTexCoord4dSGIS", "void", [ [ "GLenum", "target" ],
381 [ "GLdouble", "q" ] ], "glMultiTexCoord4dSGIS" ],
382 "glMultiTexCoord4dvSGIS" => [ "glMultiTexCoord4dvSGIS", "void", [ [ "GLenum", "target" ],
383 [ "GLdouble *", "v" ] ], "glMultiTexCoord4dvSGIS" ],
384 "glMultiTexCoord4fSGIS" => [ "glMultiTexCoord4fSGIS", "void", [ [ "GLenum", "target" ],
388 [ "GLfloat", "q" ] ], "glMultiTexCoord4fSGIS" ],
389 "glMultiTexCoord4fvSGIS" => [ "glMultiTexCoord4fvSGIS", "void", [ [ "GLenum", "target" ],
390 [ "GLfloat *", "v" ] ], "glMultiTexCoord4fvSGIS" ],
391 "glMultiTexCoord4iSGIS" => [ "glMultiTexCoord4iSGIS", "void", [ [ "GLenum", "target" ],
395 [ "GLint", "q" ] ], "glMultiTexCoord4iSGIS" ],
396 "glMultiTexCoord4ivSGIS" => [ "glMultiTexCoord4ivSGIS", "void", [ [ "GLenum", "target" ],
397 [ "GLint *", "v" ] ], "glMultiTexCoord4ivSGIS" ],
398 "glMultiTexCoord4sSGIS" => [ "glMultiTexCoord4sSGIS", "void", [ [ "GLenum", "target" ],
402 [ "GLshort", "q" ] ], "glMultiTexCoord4sSGIS" ],
403 "glMultiTexCoord4svSGIS" => [ "glMultiTexCoord4svSGIS", "void", [ [ "GLenum", "target" ],
404 [ "GLshort *", "v" ] ], "glMultiTexCoord4svSGIS" ],
405 "glMultiTexCoordPointerSGIS" => [ "glMultiTexCoordPointerSGIS", "void", [ [ "GLenum", "target" ],
407 [ "GLenum", "type" ],
408 [ "GLsizei", "stride" ],
409 [ "GLvoid *", "pointer" ] ], "glMultiTexCoordPointerSGIS" ],
410 "glSelectTextureSGIS" => [ "glSelectTextureSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureSGIS" ],
411 "glSelectTextureCoordSetSGIS" => [ "glSelectTextureCoordSetSGIS", "void", [ [ "GLenum", "target" ] ], "glSelectTextureCoordSetSGIS" ],
412 "wglAllocateMemoryNV" => [ "wglAllocateMemoryNV", "void *", [ [ "GLsizei", "size" ],
413 [ "GLfloat", "readfreq" ],
414 [ "GLfloat", "writefreq"],
415 [ "GLfloat", "priority" ] ], "glXAllocateMemoryNV" ],
416 "wglFreeMemoryNV" => [ "wglFreeMemoryNV", "void", [ [ "GLvoid *", "pointer" ] ], "glXFreeMemoryNV" ]
420 while ($line = <REGISTRY>) {
421 if ($line =~ /^\w*\(.*\)/) {
422 # Get the function name (NOTE: the 'gl' prefix needs to be added later)
423 ($funcname, $args) = ($line =~ /^(\w*)\((.*)\)/);
424 # and the argument names
425 @arg_names = split /\s*,\s*/, $args;
429 # - the argument types
430 # - the category the function belongs
436 unless (defined($line)) {
438 } elsif ($line =~ /^\s*$/) {
439 if (($category eq "") || ($ret_type eq "")) {
440 die "Missing 'category' line in function $funcname.\n";
443 } elsif ($line =~ /\t*return\t*(\w*)/) {
444 ($ret_type) = ($line =~ /\t*return\s*(\w*)/);
445 $ret_type = $pseudo_to_opengl{$ret_type};
446 unless (defined($ret_type)) {
447 die "Unsupported return type in function $funcname\n";
449 } elsif ($line =~ /^\t*category/) {
450 ($category) = ($line =~ /^\t*category\s*([\w-]*)/);
451 } elsif ($line =~ /^\t*param/) {
452 ($name, $base_type, $ext) = ($line =~ /\t*param\s*(\w*)\s*(\w*) (.*)/);
454 unless (defined($name)) {
456 die "Broken spec file line $line in function $funcname\n";
459 if ($ext =~ /array/) {
462 } elsif ($ext =~ /value/) {
463 # And this a 'normal' value
467 die "Unsupported type : $line in function $funcname\n";
469 # Get the 'real' type and append a '*' in case of a pointer
470 $type = $pseudo_to_opengl{$base_type};
471 unless (defined($type)) {
473 die "Unsupported return type in function $funcname for type $base_type (line $line)\n";
479 $arg_types{$name} = $type;
483 # Now, build the argument reference
485 for ($i = 0; $i <= $#arg_names; $i++) {
486 unless (defined($arg_types{$arg_names[$i]})) {
487 print "@arg_names\n";
488 foreach (sort keys %arg_types) {
489 print "$_ => $arg_types{$_}\n";
491 die "Undefined type for $arg_names[$i] in function $funcname\n";
494 push @$arg_ref, [ $arg_types{$arg_names[$i]}, $arg_names[$i] ];
496 $func_ref = [ "gl" . $funcname,
501 # Now, put in one or the other hash table
502 if ($norm_categories{$category}) {
503 $norm_functions{"gl" . $funcname} = $func_ref;
505 $ext_functions{"gl" . $funcname} = $func_ref;
511 # Clean up the input files
517 # Now, generate the output files. First, the spec file.
519 open(SPEC, ">" . $spec_file);
521 print SPEC "@ stdcall wglCreateContext(long)
522 @ stdcall wglCreateLayerContext(long long)
523 @ stdcall wglCopyContext(long long long)
524 @ stdcall wglDeleteContext(long)
525 @ stdcall wglDescribeLayerPlane(long long long long ptr)
526 @ stdcall wglGetCurrentContext()
527 @ stdcall wglGetCurrentDC()
528 @ stdcall wglGetExtensionsStringEXT()
529 @ stdcall wglGetExtensionsStringARB(long)
530 @ stdcall wglGetLayerPaletteEntries(long long long long ptr)
531 @ stdcall wglGetProcAddress(str)
532 @ stdcall wglMakeCurrent(long long)
533 @ stdcall wglRealizeLayerPalette(long long long)
534 @ stdcall wglSetLayerPaletteEntries(long long long long ptr)
535 @ stdcall wglShareLists(long long)
536 @ stdcall wglSwapLayerBuffers(long long)
537 @ stdcall wglUseFontBitmapsA(long long long long)
538 @ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
539 @ stub glGetLevelParameterfv
540 @ stub glGetLevelParameteriv
541 @ stub wglUseFontBitmapsW
542 @ stub wglUseFontOutlinesW
543 @ stub wglGetDefaultProcAddress
544 @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat
545 @ stdcall wglDescribePixelFormat(long long long ptr) gdi32.DescribePixelFormat
546 @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat
547 @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat
548 @ stdcall wglSwapBuffers(long) gdi32.SwapBuffers
551 foreach (sort keys %norm_functions) {
552 $func_name = $norm_functions{$_}->[0];
553 print SPEC "@ stdcall $func_name( ";
554 for ($i = 0; $i <= $#{@{$norm_functions{$_}->[2]}}; $i++) {
555 $type = $norm_functions{$_}->[2]->[$i]->[0];
558 } elsif (defined($arg_conv{$type})) {
559 print SPEC "$@$arg_conv{$type}[0] ";
561 die "No convertion for GL type $type...\n";
564 print SPEC ") wine_$func_name\n";
569 # After the spec file, the opengl_norm.c file
571 open(NORM, ">" . $norm_file);
573 /* Auto-generated file... Do not edit ! */
575 #include \"config.h\"
576 #include \"opengl_ext.h\"
577 #include \"wine/debug.h\"
579 typedef const GLubyte * GLstring;
581 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
584 foreach (sort keys %norm_functions) {
585 $string = GenerateThunk($norm_functions{$_}, 1, "", $gen_thread_safe);
587 print NORM "$string\n";
592 # Finally, more complex, the opengl_ext.c file
594 open(EXT, ">" . $ext_file);
596 /* Auto-generated file... Do not edit ! */
598 #include \"config.h\"
599 #include \"opengl_ext.h\"
600 #include \"wine/debug.h\"
602 typedef const GLubyte * GLstring;
604 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
606 typedef ptrdiff_t GLintptrARB;
607 typedef ptrdiff_t GLsizeiptrARB;
608 typedef unsigned short GLhalfNV;
612 # First, generate the function pointers
613 foreach (sort keys %ext_functions) {
614 $func_ref = $ext_functions{$_};
615 print EXT $func_ref->[1] . " (*" . $ext_prefix . $func_ref->[0] . ")( ";
616 for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
617 $type = $func_ref->[2]->[$i]->[0];
619 if ($i != $#{@{$func_ref->[2]}}) {
625 print EXT ") = (void *) 0xdeadbeef;\n";
628 # Then, the function prototypes
629 print EXT "\n\n/* The function prototypes */\n";
630 foreach (sort keys %ext_functions) {
631 $func_ref = $ext_functions{$_};
632 print EXT $func_ref->[1] . " WINAPI " . "wine_" . $func_ref->[0] . "( ";
633 for ($i = 0; $i <= $#{@{$func_ref->[2]}}; $i++) {
634 $type = $func_ref->[2]->[$i]->[0];
636 if ($i != $#{@{$func_ref->[2]}}) {
645 # Then the table giving the string <-> function correspondance */
646 print EXT "\n\n/* The table giving the correspondance between names and functions */\n";
647 @tmp = keys %ext_functions;
648 print EXT "int extension_registry_size = " . ($#tmp + 1) . ";\n";
649 print EXT "OpenGL_extension extension_registry[" . ($#tmp + 1) . "] = {\n";
651 foreach (sort keys %ext_functions) {
652 $func_ref = $ext_functions{$_};
653 print EXT " { \"" . $func_ref->[0] . "\", \"" . $func_ref->[3] . "\", (void *) wine_" . $func_ref->[0] . ", (void **) (&" . $ext_prefix . $func_ref->[0] . ") }";
662 # And, finally, the thunks themselves....
663 print EXT "\n/* The thunks themselves....*/\n";
664 foreach (sort keys %ext_functions) {
665 $string = GenerateThunk($ext_functions{$_}, 0, $ext_prefix, $gen_thread_safe);
667 print EXT "$string\n";