Added support for OpenGL.
[wine.git] / dlls / opengl32 / make_opengl_ext
blob16a9548964c87328b9dc8bfa7f9cf7ab8fd46a9b
1 #!/usr/bin/perl -w
3 print "
4 /* Auto-generated file... Do not edit ! */
6 #include \"config.h\"
7 #include \"wine_gl.h\"
9 #include \"opengl_ext.h\"
14 # First, create a hash-table with all function defined in opengl32.spec
16 %opengl_std = ();
17 open(SPEC, "dlls/opengl32/opengl32.spec") || die "Could not open spec file";
18 foreach (<SPEC>) {
19 if (($_ =~ /@/) && ($_ !~ /wgl/)) {
20 ($name) = ($_ =~ /stdcall (\w*)\(/);
21 $opengl_std{$name} = 1;
24 close(SPEC);
27 # Now, the functions from the include file
29 %opengl_ext = ();
30 open(INC, "/home/ulmer/OpenGL/glext_proto.h") || die "Could not open GL/glext.h";
31 while ($line = <INC>) {
32 if ($line =~ /extern.*APIENTRY/) {
33 # Start of a function declaration
34 ($ret, $name, $args) = ($line =~ /extern (\w*) APIENTRY *(\w*) *\((.*)\)/);
36 # Now, remove all function already defined in opengl32.spec
37 if ($opengl_std{$name}) {
38 # Do nothing as we already have these functions
39 } else {
40 # Now, get the typedef name (the line after)
41 ($typedef_name) = (<INC> =~ /\(APIENTRY *\* *(\w*) *\)/);
43 # After that, parse the arguments
44 @args = split /,/, $args;
45 $args_ref = [];
46 foreach (@args) {
47 push @$args_ref, $_;
49 $opengl_ext{$name} = [ $ret, $typedef_name, $args_ref ];
53 close(INC);
56 # After that, generate the file itself....
58 print "/* These will be filled during a wglGetProcAddress call */\n";
59 $num = 0;
60 foreach $name (sort keys(%opengl_ext)) {
61 $ref = $opengl_ext{$name};
62 $arg_ref = $$ref[2];
63 @larg = @$arg_ref;
65 print "$$ref[0] (*func_$name)(";
66 $farg = shift @larg;
67 print "$farg";
68 foreach (@larg) {
69 print ", $_";
71 print ") = (void *) 0xdeadbeef;\n";
72 $num++;
74 print "\n";
76 print "/* The function prototypes */\n";
77 foreach $name (sort keys(%opengl_ext)) {
78 $ref = $opengl_ext{$name};
79 $arg_ref = $$ref[2];
80 @larg = @$arg_ref;
81 print "$$ref[0] WINAPI wine_$name(";
83 $farg = shift @larg;
84 print "$farg";
85 foreach (@larg) {
86 print ", $_";
88 print ") ;\n";
90 print "\n";
93 print "/* The table giving the correspondance between names and functions */\n";
94 print "int extension_registry_size = $num;\n";
95 print "OpenGL_extension extension_registry[] = {\n";
96 foreach $name (sort keys(%opengl_ext)) {
97 $num--;
98 print " { \"$name\", (void *) wine_$name, (void **) (&func_$name) }";
99 if ($num) {
100 print ",";
102 print "\n";
104 print "};\n";
105 print "\n";
107 print "/* Now, the function declarations */\n";
108 foreach $name (sort keys(%opengl_ext)) {
109 $ref = $opengl_ext{$name};
110 $arg_ref = $$ref[2];
111 print "$$ref[0] WINAPI wine_$name(";
113 $farg = shift @$arg_ref;
114 $num = 0;
115 if ($farg !~ /void/) {
116 print "$farg arg_0";
117 $num++;
118 foreach (@$arg_ref) {
119 print ", $_ arg_$num";
120 $num++;
123 print ") {\n";
124 if ($$ref[0] !~ /void/) {
125 print " $$ref[0] ret;\n"
127 print " ENTER_GL();\n";
128 print " ";
129 if ($$ref[0] !~ /void/) {
130 print " ret = ";
132 print "func_$name(";
133 if ($num > 0) {
134 print "arg_0";
135 for ($i = 1; $i < $num; $i++) {
136 print ", arg_$i";
139 print ");\n";
140 print " LEAVE_GL();\n";
141 if ($$ref[0] !~ /void/) {
142 print " return ret;\n"
144 print "}\n\n";