~ubuntu-branches/ubuntu/gutsy/gtkglext/gutsy

« back to all changes in this revision

Viewing changes to gdk/glext/gen-gdkglglxext-h.pl

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2004-04-03 17:43:17 UTC
  • Revision ID: james.westby@ubuntu.com-20040403174317-d5gb2d2gftaligp8
Tags: upstream-1.0.6
ImportĀ upstreamĀ versionĀ 1.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
#
 
3
# gen-gdkglglxext-h.pl
 
4
#
 
5
# Script for generating gdk/x11/gdkglglxext.h from SGI's OpenGL extension
 
6
# header.
 
7
#
 
8
# written by Naofumi Yasufuku <naofumi@users.sourceforge.net>
 
9
#
 
10
 
 
11
@input_headers = ("glxext.h", "glxext-extra.h");
 
12
 
 
13
#---------------
 
14
open(IN, "common-header.h") || die "cannot open common-header.h";
 
15
print while (<IN>);
 
16
close(IN);
 
17
 
 
18
print <<EOF;
 
19
/*
 
20
 * This is a generated file.  Please modify "gen-gdkglglxext-h.pl".
 
21
 */
 
22
 
 
23
#ifndef __GDK_GL_GLXEXT_H__
 
24
#define __GDK_GL_GLXEXT_H__
 
25
 
 
26
#include <X11/Xlib.h>
 
27
#include <X11/Xutil.h>
 
28
 
 
29
#include <GL/gl.h>
 
30
#include <GL/glx.h>
 
31
 
 
32
#include <gdk/gdkgldefs.h>
 
33
#include <gdk/gdkglquery.h>
 
34
#include <gdk/gdkglconfig.h>
 
35
 
 
36
G_BEGIN_DECLS
 
37
 
 
38
#ifndef GLX_VERSION_1_3
 
39
typedef struct __GLXFBConfigRec *GLXFBConfig;
 
40
typedef XID GLXFBConfigID;
 
41
typedef XID GLXContextID;
 
42
typedef XID GLXWindow;
 
43
typedef XID GLXPbuffer;
 
44
#endif
 
45
 
 
46
#ifndef HAVE_GLXFBCONFIGSGIX
 
47
#if defined(GLX_SGIX_fbconfig) && defined(GDKGLEXT_NEED_GLXFBCONFIGSGIX_TYPEDEF)
 
48
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
 
49
#endif
 
50
#endif
 
51
 
 
52
#ifndef HAVE_GLXFBCONFIGIDSGIX
 
53
#if defined(GLX_SGIX_fbconfig) && defined(GDKGLEXT_NEED_GLXFBCONFIGIDSGIX_TYPEDEF)
 
54
typedef XID GLXFBConfigIDSGIX;
 
55
#endif
 
56
#endif
 
57
 
 
58
#ifndef HAVE_GLXPBUFFERSGIX
 
59
#if defined(GLX_SGIX_pbuffer) && defined(GDKGLEXT_NEED_GLXPBUFFERSGIX_TYPEDEF)
 
60
typedef XID GLXPbufferSGIX;
 
61
#endif
 
62
#endif
 
63
 
 
64
/* for __GLXextFuncPtr typedef in glxext.h */
 
65
#ifndef HAVE___GLXEXTFUNCPTR
 
66
#if defined(GLX_ARB_get_proc_address) && defined(GDKGLEXT_NEED_GLXEXTFUNCPTR_TYPEDEF)
 
67
#undef GLX_ARB_get_proc_address
 
68
#endif
 
69
#endif
 
70
 
 
71
/* Suppress 'redefined' warnings (Solaris 8, etc.) */
 
72
 
 
73
#if !defined(GLX_ARB_multisample) && defined(GLX_SAMPLE_BUFFERS_ARB)
 
74
#define GLX_ARB_multisample 1
 
75
#endif
 
76
 
 
77
#if !defined(GLX_SGIS_multisample) && defined(GLX_SAMPLE_BUFFERS_SGIS)
 
78
#define GLX_SGIS_multisample 1
 
79
#endif
 
80
 
 
81
#if !defined(GLX_EXT_visual_rating) && defined(GLX_VISUAL_CAVEAT_EXT)
 
82
#define GLX_EXT_visual_rating 1
 
83
#endif
 
84
 
 
85
#if !defined(GLX_EXT_import_context) && defined(GLX_SHARE_CONTEXT_EXT)
 
86
#define GLX_EXT_import_context 1
 
87
#endif
 
88
 
 
89
/* Avoid old glxext.h bug. */
 
90
#if !defined(GLX_SGIX_video_source) && !defined(GDKGLEXT_NEED_GLXVIDEOSOURCESGIX_TYPEDEF)
 
91
#define GLX_SGIX_video_source 1
 
92
#endif
 
93
 
 
94
#undef __glxext_h_
 
95
#undef GLX_GLXEXT_VERSION
 
96
#include <gdk/glext/glxext.h>
 
97
#include <gdk/glext/glxext-extra.h>
 
98
 
 
99
EOF
 
100
#---------------
 
101
 
 
102
foreach $in (@input_headers) {
 
103
    open(IN, $in) || die "cannot open $in";
 
104
 
 
105
    while (<IN>) {
 
106
        if (/#ifndef\s+GLX_[a-zA-Z0-9]+_[a-z0-9_]+/) {
 
107
            @line = split;
 
108
            $_ = <IN>;
 
109
            if (/#define\s+$line[1]/) {
 
110
                while (<IN>) {
 
111
                    if (/#ifdef\s+GLX_GLXEXT_PROTOTYPES/) {
 
112
 
 
113
                        $extension = $line[1];
 
114
 
 
115
                        # function prototypes
 
116
                        @functions = ();
 
117
                        while (<IN>) {
 
118
                            last if (/#endif/);
 
119
                            ($func) = /(glX\w+)/;
 
120
                            push(@functions, $func);
 
121
                        }
 
122
 
 
123
                        # typedefs
 
124
                        @typedefs = ();
 
125
                        while (<IN>) {
 
126
                            last if (/#endif/);
 
127
                            chomp;
 
128
                            push(@typedefs, $_);
 
129
                        }
 
130
 
 
131
                        generate_code();
 
132
 
 
133
                        last;
 
134
 
 
135
                    } elsif (/#endif/) {
 
136
                        last;
 
137
                    }
 
138
                }
 
139
            }
 
140
        }
 
141
    }
 
142
 
 
143
    close(IN);
 
144
}
 
145
 
 
146
#---------------
 
147
print <<EOF;
 
148
G_END_DECLS
 
149
 
 
150
#endif /* __GDK_GL_GLXEXT_H__ */
 
151
EOF
 
152
#---------------
 
153
 
 
154
# code generator
 
155
sub generate_code {
 
156
    print "/*\n";
 
157
    print " * $extension\n";
 
158
    print " */\n\n";
 
159
 
 
160
    if ($extension eq "GLX_SGIX_video_source") {
 
161
        print "#ifdef _VL_H\n\n";
 
162
    } elsif ($extension eq "GLX_SGIX_dmbuffer") {
 
163
        print "#ifdef _DM_BUFFER_H_\n\n";
 
164
    }
 
165
 
 
166
    $i = 0;
 
167
    foreach $func (@functions) {
 
168
        print "/* $func */\n";
 
169
 
 
170
        $type = $typedefs[$i++];
 
171
        $type =~ s/PFN\w+/GdkGLProc_$func/;
 
172
        print "$type\n";
 
173
 
 
174
        print "GdkGLProc    gdk_gl_get_$func (void);\n";
 
175
 
 
176
        $_ = $type;
 
177
        ($args) = /\(.*\)\s+\((.*)\)/;
 
178
        @args_list = split(/,\s+/, $args);
 
179
        foreach (@args_list) {
 
180
            ($_) = /.*\s+\**(\w+)$/;
 
181
            $_ = "" if (!$_);
 
182
        }
 
183
        $args = join(", ", @args_list);
 
184
 
 
185
        if ($args eq "") {
 
186
            print "#define      gdk_gl_$func(proc) \\\n";
 
187
            print "  ( ((GdkGLProc_$func) (proc)) () )\n";
 
188
        } else {
 
189
            print "#define      gdk_gl_$func(proc, $args) \\\n";
 
190
            print "  ( ((GdkGLProc_$func) (proc)) ($args) )\n";
 
191
        }
 
192
 
 
193
        print "\n";
 
194
    }
 
195
 
 
196
    print "/* proc struct */\n\n";
 
197
 
 
198
    print "typedef struct _GdkGL_$extension GdkGL_$extension;\n\n";
 
199
 
 
200
    print "struct _GdkGL_$extension\n";
 
201
    print "{\n";
 
202
    foreach $func (@functions) {
 
203
        print "  GdkGLProc_$func $func;\n";
 
204
    }
 
205
    print "};\n\n";
 
206
 
 
207
    if ($extension =~ /^GLX_VERSION_.*/) {
 
208
        print "GdkGL_$extension *gdk_gl_get_$extension (void);\n\n";
 
209
    } else {
 
210
        print "GdkGL_$extension *gdk_gl_get_$extension (GdkGLConfig *glconfig);\n\n";
 
211
    }
 
212
 
 
213
    if ($extension eq "GLX_SGIX_video_source") {
 
214
        print "#endif /* _VL_H */\n\n";
 
215
    } elsif ($extension eq "GLX_SGIX_dmbuffer") {
 
216
        print "#endif /* _DM_BUFFER_H_ */\n\n";
 
217
    }
 
218
}