]> git.cworth.org Git - apitrace/blob - glproc.py
Put license in a separate file.
[apitrace] / glproc.py
1 ##########################################################################
2 #
3 # Copyright 2010 VMware, Inc.
4 # All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 ##########################################################################/
25
26
27 """Generated an header, glproc.hpp, which does pretty much what GLEW does, but
28 covers all the functions we support.
29 """ 
30
31
32 import stdapi
33 from dispatch import Dispatcher
34 from glapi import glapi
35 from glxapi import glxapi
36 from wglapi import wglapi
37
38
39 # See http://www.opengl.org/registry/ABI/
40 public_symbols = set([
41         "glAccum",
42         "glAlphaFunc",
43         "glAreTexturesResident",
44         "glArrayElement",
45         "glBegin",
46         "glBindTexture",
47         "glBitmap",
48         "glBlendFunc",
49         "glCallList",
50         "glCallLists",
51         "glClear",
52         "glClearAccum",
53         "glClearColor",
54         "glClearDepth",
55         "glClearIndex",
56         "glClearStencil",
57         "glClipPlane",
58         "glColor3b",
59         "glColor3bv",
60         "glColor3d",
61         "glColor3dv",
62         "glColor3f",
63         "glColor3fv",
64         "glColor3i",
65         "glColor3iv",
66         "glColor3s",
67         "glColor3sv",
68         "glColor3ub",
69         "glColor3ubv",
70         "glColor3ui",
71         "glColor3uiv",
72         "glColor3us",
73         "glColor3usv",
74         "glColor4b",
75         "glColor4bv",
76         "glColor4d",
77         "glColor4dv",
78         "glColor4f",
79         "glColor4fv",
80         "glColor4i",
81         "glColor4iv",
82         "glColor4s",
83         "glColor4sv",
84         "glColor4ub",
85         "glColor4ubv",
86         "glColor4ui",
87         "glColor4uiv",
88         "glColor4us",
89         "glColor4usv",
90         "glColorMask",
91         "glColorMaterial",
92         "glColorPointer",
93         "glCopyPixels",
94         "glCopyTexImage1D",
95         "glCopyTexImage2D",
96         "glCopyTexSubImage1D",
97         "glCopyTexSubImage2D",
98         "glCullFace",
99 #       "glDebugEntry",
100         "glDeleteLists",
101         "glDeleteTextures",
102         "glDepthFunc",
103         "glDepthMask",
104         "glDepthRange",
105         "glDisable",
106         "glDisableClientState",
107         "glDrawArrays",
108         "glDrawBuffer",
109         "glDrawElements",
110         "glDrawPixels",
111         "glEdgeFlag",
112         "glEdgeFlagPointer",
113         "glEdgeFlagv",
114         "glEnable",
115         "glEnableClientState",
116         "glEnd",
117         "glEndList",
118         "glEvalCoord1d",
119         "glEvalCoord1dv",
120         "glEvalCoord1f",
121         "glEvalCoord1fv",
122         "glEvalCoord2d",
123         "glEvalCoord2dv",
124         "glEvalCoord2f",
125         "glEvalCoord2fv",
126         "glEvalMesh1",
127         "glEvalMesh2",
128         "glEvalPoint1",
129         "glEvalPoint2",
130         "glFeedbackBuffer",
131         "glFinish",
132         "glFlush",
133         "glFogf",
134         "glFogfv",
135         "glFogi",
136         "glFogiv",
137         "glFrontFace",
138         "glFrustum",
139         "glGenLists",
140         "glGenTextures",
141         "glGetBooleanv",
142         "glGetClipPlane",
143         "glGetDoublev",
144         "glGetError",
145         "glGetFloatv",
146         "glGetIntegerv",
147         "glGetLightfv",
148         "glGetLightiv",
149         "glGetMapdv",
150         "glGetMapfv",
151         "glGetMapiv",
152         "glGetMaterialfv",
153         "glGetMaterialiv",
154         "glGetPixelMapfv",
155         "glGetPixelMapuiv",
156         "glGetPixelMapusv",
157         "glGetPointerv",
158         "glGetPolygonStipple",
159         "glGetString",
160         "glGetTexEnvfv",
161         "glGetTexEnviv",
162         "glGetTexGendv",
163         "glGetTexGenfv",
164         "glGetTexGeniv",
165         "glGetTexImage",
166         "glGetTexLevelParameterfv",
167         "glGetTexLevelParameteriv",
168         "glGetTexParameterfv",
169         "glGetTexParameteriv",
170         "glHint",
171         "glIndexMask",
172         "glIndexPointer",
173         "glIndexd",
174         "glIndexdv",
175         "glIndexf",
176         "glIndexfv",
177         "glIndexi",
178         "glIndexiv",
179         "glIndexs",
180         "glIndexsv",
181         "glIndexub",
182         "glIndexubv",
183         "glInitNames",
184         "glInterleavedArrays",
185         "glIsEnabled",
186         "glIsList",
187         "glIsTexture",
188         "glLightModelf",
189         "glLightModelfv",
190         "glLightModeli",
191         "glLightModeliv",
192         "glLightf",
193         "glLightfv",
194         "glLighti",
195         "glLightiv",
196         "glLineStipple",
197         "glLineWidth",
198         "glListBase",
199         "glLoadIdentity",
200         "glLoadMatrixd",
201         "glLoadMatrixf",
202         "glLoadName",
203         "glLogicOp",
204         "glMap1d",
205         "glMap1f",
206         "glMap2d",
207         "glMap2f",
208         "glMapGrid1d",
209         "glMapGrid1f",
210         "glMapGrid2d",
211         "glMapGrid2f",
212         "glMaterialf",
213         "glMaterialfv",
214         "glMateriali",
215         "glMaterialiv",
216         "glMatrixMode",
217         "glMultMatrixd",
218         "glMultMatrixf",
219         "glNewList",
220         "glNormal3b",
221         "glNormal3bv",
222         "glNormal3d",
223         "glNormal3dv",
224         "glNormal3f",
225         "glNormal3fv",
226         "glNormal3i",
227         "glNormal3iv",
228         "glNormal3s",
229         "glNormal3sv",
230         "glNormalPointer",
231         "glOrtho",
232         "glPassThrough",
233         "glPixelMapfv",
234         "glPixelMapuiv",
235         "glPixelMapusv",
236         "glPixelStoref",
237         "glPixelStorei",
238         "glPixelTransferf",
239         "glPixelTransferi",
240         "glPixelZoom",
241         "glPointSize",
242         "glPolygonMode",
243         "glPolygonOffset",
244         "glPolygonStipple",
245         "glPopAttrib",
246         "glPopClientAttrib",
247         "glPopMatrix",
248         "glPopName",
249         "glPrioritizeTextures",
250         "glPushAttrib",
251         "glPushClientAttrib",
252         "glPushMatrix",
253         "glPushName",
254         "glRasterPos2d",
255         "glRasterPos2dv",
256         "glRasterPos2f",
257         "glRasterPos2fv",
258         "glRasterPos2i",
259         "glRasterPos2iv",
260         "glRasterPos2s",
261         "glRasterPos2sv",
262         "glRasterPos3d",
263         "glRasterPos3dv",
264         "glRasterPos3f",
265         "glRasterPos3fv",
266         "glRasterPos3i",
267         "glRasterPos3iv",
268         "glRasterPos3s",
269         "glRasterPos3sv",
270         "glRasterPos4d",
271         "glRasterPos4dv",
272         "glRasterPos4f",
273         "glRasterPos4fv",
274         "glRasterPos4i",
275         "glRasterPos4iv",
276         "glRasterPos4s",
277         "glRasterPos4sv",
278         "glReadBuffer",
279         "glReadPixels",
280         "glRectd",
281         "glRectdv",
282         "glRectf",
283         "glRectfv",
284         "glRecti",
285         "glRectiv",
286         "glRects",
287         "glRectsv",
288         "glRenderMode",
289         "glRotated",
290         "glRotatef",
291         "glScaled",
292         "glScalef",
293         "glScissor",
294         "glSelectBuffer",
295         "glShadeModel",
296         "glStencilFunc",
297         "glStencilMask",
298         "glStencilOp",
299         "glTexCoord1d",
300         "glTexCoord1dv",
301         "glTexCoord1f",
302         "glTexCoord1fv",
303         "glTexCoord1i",
304         "glTexCoord1iv",
305         "glTexCoord1s",
306         "glTexCoord1sv",
307         "glTexCoord2d",
308         "glTexCoord2dv",
309         "glTexCoord2f",
310         "glTexCoord2fv",
311         "glTexCoord2i",
312         "glTexCoord2iv",
313         "glTexCoord2s",
314         "glTexCoord2sv",
315         "glTexCoord3d",
316         "glTexCoord3dv",
317         "glTexCoord3f",
318         "glTexCoord3fv",
319         "glTexCoord3i",
320         "glTexCoord3iv",
321         "glTexCoord3s",
322         "glTexCoord3sv",
323         "glTexCoord4d",
324         "glTexCoord4dv",
325         "glTexCoord4f",
326         "glTexCoord4fv",
327         "glTexCoord4i",
328         "glTexCoord4iv",
329         "glTexCoord4s",
330         "glTexCoord4sv",
331         "glTexCoordPointer",
332         "glTexEnvf",
333         "glTexEnvfv",
334         "glTexEnvi",
335         "glTexEnviv",
336         "glTexGend",
337         "glTexGendv",
338         "glTexGenf",
339         "glTexGenfv",
340         "glTexGeni",
341         "glTexGeniv",
342         "glTexImage1D",
343         "glTexImage2D",
344         "glTexParameterf",
345         "glTexParameterfv",
346         "glTexParameteri",
347         "glTexParameteriv",
348         "glTexSubImage1D",
349         "glTexSubImage2D",
350         "glTranslated",
351         "glTranslatef",
352         "glVertex2d",
353         "glVertex2dv",
354         "glVertex2f",
355         "glVertex2fv",
356         "glVertex2i",
357         "glVertex2iv",
358         "glVertex2s",
359         "glVertex2sv",
360         "glVertex3d",
361         "glVertex3dv",
362         "glVertex3f",
363         "glVertex3fv",
364         "glVertex3i",
365         "glVertex3iv",
366         "glVertex3s",
367         "glVertex3sv",
368         "glVertex4d",
369         "glVertex4dv",
370         "glVertex4f",
371         "glVertex4fv",
372         "glVertex4i",
373         "glVertex4iv",
374         "glVertex4s",
375         "glVertex4sv",
376         "glVertexPointer",
377         "glViewport",
378         "wglChoosePixelFormat",
379         "wglCopyContext",
380         "wglCreateContext",
381         "wglCreateLayerContext",
382         "wglDeleteContext",
383         "wglDescribeLayerPlane",
384         "wglDescribePixelFormat",
385         "wglGetCurrentContext",
386         "wglGetCurrentDC",
387         "wglGetDefaultProcAddress",
388         "wglGetLayerPaletteEntries",
389         "wglGetPixelFormat",
390         "wglGetProcAddress",
391         "wglMakeCurrent",
392         "wglRealizeLayerPalette",
393         "wglSetLayerPaletteEntries",
394         "wglSetPixelFormat",
395         "wglShareLists",
396         "wglSwapBuffers",
397         "wglSwapLayerBuffers",
398         "wglSwapMultipleBuffers",
399         "wglUseFontBitmapsA",
400         "wglUseFontBitmapsW",
401         "wglUseFontOutlinesA",
402         "wglUseFontOutlinesW",
403
404     "glXGetProcAddressARB",
405     "glXGetProcAddress",
406 ])
407
408
409 class GlDispatcher(Dispatcher):
410
411     def header(self):
412         print '#ifdef RETRACE'
413         print '#  ifdef _WIN32'
414         print '#    define __getPrivateProcAddress(name) wglGetProcAddress(name)'
415         print '#  else'
416         print '#    define __getPrivateProcAddress(name) glXGetProcAddressARB((const GLubyte *)(name))'
417         print '#  endif'
418         print '#  define __abort() OS::Abort()'
419         print '#else /* !RETRACE */'
420         print '#  ifdef _WIN32'
421         print '#    define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
422         print '     static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
423         print '#  else'
424         print '#    define __getPublicProcAddress(name) __dlsym(name)'
425         print '#    define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
426         print '     static void * __dlsym(const char *symbol);'
427         print '     static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
428         print '#  endif'
429         print '#  define __abort() Trace::Abort()'
430         print '#endif /* !RETRACE */'
431         print
432         
433     def is_public_function(self, function):
434         return function.name in public_symbols
435
436
437 if __name__ == '__main__':
438     print
439     print '#ifndef _GLPROC_HPP_'
440     print '#define _GLPROC_HPP_'
441     print 
442     print '#include "glimports.hpp"'
443     print '#include "os.hpp"'
444     print
445     print
446     dispatcher = GlDispatcher()
447     dispatcher.header()
448     print '#ifdef _WIN32'
449     print
450     dispatcher.dispatch_api(wglapi)
451     print '#else /* !_WIN32 */'
452     print
453     dispatcher.dispatch_api(glxapi)
454     print '#endif /* !_WIN32 */'
455     print
456     dispatcher.dispatch_api(glapi)
457     print
458     print '#endif /* !_GLPROC_HPP_ */'
459     print