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