blob: a086055ca97eeb30354e4ea063c7b053fbafcf0a [file] [log] [blame]
José Fonsecac6b49ce2010-11-28 16:43:04 +00001##########################################################################
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
José Fonseca4a826ed2010-11-30 16:58:22 +000027"""Generated an header, glproc.hpp, which does pretty much what GLEW does, but
28covers all the functions we support.
29"""
30
31
José Fonsecabd86a222011-09-27 09:21:38 +010032import specs.stdapi as stdapi
José Fonseca669b2002011-02-20 13:32:19 +000033from dispatch import Dispatcher
José Fonsecabd86a222011-09-27 09:21:38 +010034from specs.glapi import glapi
35from specs.glxapi import glxapi
36from specs.wglapi import wglapi
37from specs.cglapi import cglapi
Chia-I Wue50c14b2011-11-03 12:24:53 +080038from specs.eglapi import eglapi
José Fonsecac6b49ce2010-11-28 16:43:04 +000039
40
José Fonseca68ec4122011-02-20 11:25:25 +000041# See http://www.opengl.org/registry/ABI/
José Fonsecac6b49ce2010-11-28 16:43:04 +000042public_symbols = set([
José Fonsecab87c2292011-10-09 14:56:16 +010043 # GL 1.2 and ARB_multitexture
44 "glAccum",
45 "glAlphaFunc",
46 "glAreTexturesResident",
47 "glArrayElement",
48 "glBegin",
49 "glBindTexture",
50 "glBitmap",
51 "glBlendFunc",
52 "glCallList",
53 "glCallLists",
54 "glClear",
55 "glClearAccum",
56 "glClearColor",
57 "glClearDepth",
58 "glClearIndex",
59 "glClearStencil",
60 "glClipPlane",
61 "glColor3b",
62 "glColor3bv",
63 "glColor3d",
64 "glColor3dv",
65 "glColor3f",
66 "glColor3fv",
67 "glColor3i",
68 "glColor3iv",
69 "glColor3s",
70 "glColor3sv",
71 "glColor3ub",
72 "glColor3ubv",
73 "glColor3ui",
74 "glColor3uiv",
75 "glColor3us",
76 "glColor3usv",
77 "glColor4b",
78 "glColor4bv",
79 "glColor4d",
80 "glColor4dv",
81 "glColor4f",
82 "glColor4fv",
83 "glColor4i",
84 "glColor4iv",
85 "glColor4s",
86 "glColor4sv",
87 "glColor4ub",
88 "glColor4ubv",
89 "glColor4ui",
90 "glColor4uiv",
91 "glColor4us",
92 "glColor4usv",
93 "glColorMask",
94 "glColorMaterial",
95 "glColorPointer",
96 "glCopyPixels",
97 "glCopyTexImage1D",
98 "glCopyTexImage2D",
99 "glCopyTexSubImage1D",
100 "glCopyTexSubImage2D",
101 "glCullFace",
102 "glDeleteLists",
103 "glDeleteTextures",
104 "glDepthFunc",
105 "glDepthMask",
106 "glDepthRange",
107 "glDisable",
108 "glDisableClientState",
109 "glDrawArrays",
110 "glDrawBuffer",
111 "glDrawElements",
112 "glDrawPixels",
113 "glEdgeFlag",
114 "glEdgeFlagPointer",
115 "glEdgeFlagv",
116 "glEnable",
117 "glEnableClientState",
118 "glEnd",
119 "glEndList",
120 "glEvalCoord1d",
121 "glEvalCoord1dv",
122 "glEvalCoord1f",
123 "glEvalCoord1fv",
124 "glEvalCoord2d",
125 "glEvalCoord2dv",
126 "glEvalCoord2f",
127 "glEvalCoord2fv",
128 "glEvalMesh1",
129 "glEvalMesh2",
130 "glEvalPoint1",
131 "glEvalPoint2",
132 "glFeedbackBuffer",
133 "glFinish",
134 "glFlush",
135 "glFogf",
136 "glFogfv",
137 "glFogi",
138 "glFogiv",
139 "glFrontFace",
140 "glFrustum",
141 "glGenLists",
142 "glGenTextures",
143 "glGetBooleanv",
144 "glGetClipPlane",
145 "glGetDoublev",
146 "glGetError",
147 "glGetFloatv",
148 "glGetIntegerv",
149 "glGetLightfv",
150 "glGetLightiv",
151 "glGetMapdv",
152 "glGetMapfv",
153 "glGetMapiv",
154 "glGetMaterialfv",
155 "glGetMaterialiv",
156 "glGetPixelMapfv",
157 "glGetPixelMapuiv",
158 "glGetPixelMapusv",
159 "glGetPointerv",
160 "glGetPolygonStipple",
161 "glGetString",
162 "glGetTexEnvfv",
163 "glGetTexEnviv",
164 "glGetTexGendv",
165 "glGetTexGenfv",
166 "glGetTexGeniv",
167 "glGetTexImage",
168 "glGetTexLevelParameterfv",
169 "glGetTexLevelParameteriv",
170 "glGetTexParameterfv",
171 "glGetTexParameteriv",
172 "glHint",
173 "glIndexMask",
174 "glIndexPointer",
175 "glIndexd",
176 "glIndexdv",
177 "glIndexf",
178 "glIndexfv",
179 "glIndexi",
180 "glIndexiv",
181 "glIndexs",
182 "glIndexsv",
183 "glIndexub",
184 "glIndexubv",
185 "glInitNames",
186 "glInterleavedArrays",
187 "glIsEnabled",
188 "glIsList",
189 "glIsTexture",
190 "glLightModelf",
191 "glLightModelfv",
192 "glLightModeli",
193 "glLightModeliv",
194 "glLightf",
195 "glLightfv",
196 "glLighti",
197 "glLightiv",
198 "glLineStipple",
199 "glLineWidth",
200 "glListBase",
201 "glLoadIdentity",
202 "glLoadMatrixd",
203 "glLoadMatrixf",
204 "glLoadName",
205 "glLogicOp",
206 "glMap1d",
207 "glMap1f",
208 "glMap2d",
209 "glMap2f",
210 "glMapGrid1d",
211 "glMapGrid1f",
212 "glMapGrid2d",
213 "glMapGrid2f",
214 "glMaterialf",
215 "glMaterialfv",
216 "glMateriali",
217 "glMaterialiv",
218 "glMatrixMode",
219 "glMultMatrixd",
220 "glMultMatrixf",
221 "glNewList",
222 "glNormal3b",
223 "glNormal3bv",
224 "glNormal3d",
225 "glNormal3dv",
226 "glNormal3f",
227 "glNormal3fv",
228 "glNormal3i",
229 "glNormal3iv",
230 "glNormal3s",
231 "glNormal3sv",
232 "glNormalPointer",
233 "glOrtho",
234 "glPassThrough",
235 "glPixelMapfv",
236 "glPixelMapuiv",
237 "glPixelMapusv",
238 "glPixelStoref",
239 "glPixelStorei",
240 "glPixelTransferf",
241 "glPixelTransferi",
242 "glPixelZoom",
243 "glPointSize",
244 "glPolygonMode",
245 "glPolygonOffset",
246 "glPolygonStipple",
247 "glPopAttrib",
248 "glPopClientAttrib",
249 "glPopMatrix",
250 "glPopName",
251 "glPrioritizeTextures",
252 "glPushAttrib",
253 "glPushClientAttrib",
254 "glPushMatrix",
255 "glPushName",
256 "glRasterPos2d",
257 "glRasterPos2dv",
258 "glRasterPos2f",
259 "glRasterPos2fv",
260 "glRasterPos2i",
261 "glRasterPos2iv",
262 "glRasterPos2s",
263 "glRasterPos2sv",
264 "glRasterPos3d",
265 "glRasterPos3dv",
266 "glRasterPos3f",
267 "glRasterPos3fv",
268 "glRasterPos3i",
269 "glRasterPos3iv",
270 "glRasterPos3s",
271 "glRasterPos3sv",
272 "glRasterPos4d",
273 "glRasterPos4dv",
274 "glRasterPos4f",
275 "glRasterPos4fv",
276 "glRasterPos4i",
277 "glRasterPos4iv",
278 "glRasterPos4s",
279 "glRasterPos4sv",
280 "glReadBuffer",
281 "glReadPixels",
282 "glRectd",
283 "glRectdv",
284 "glRectf",
285 "glRectfv",
286 "glRecti",
287 "glRectiv",
288 "glRects",
289 "glRectsv",
290 "glRenderMode",
291 "glRotated",
292 "glRotatef",
293 "glScaled",
294 "glScalef",
295 "glScissor",
296 "glSelectBuffer",
297 "glShadeModel",
298 "glStencilFunc",
299 "glStencilMask",
300 "glStencilOp",
301 "glTexCoord1d",
302 "glTexCoord1dv",
303 "glTexCoord1f",
304 "glTexCoord1fv",
305 "glTexCoord1i",
306 "glTexCoord1iv",
307 "glTexCoord1s",
308 "glTexCoord1sv",
309 "glTexCoord2d",
310 "glTexCoord2dv",
311 "glTexCoord2f",
312 "glTexCoord2fv",
313 "glTexCoord2i",
314 "glTexCoord2iv",
315 "glTexCoord2s",
316 "glTexCoord2sv",
317 "glTexCoord3d",
318 "glTexCoord3dv",
319 "glTexCoord3f",
320 "glTexCoord3fv",
321 "glTexCoord3i",
322 "glTexCoord3iv",
323 "glTexCoord3s",
324 "glTexCoord3sv",
325 "glTexCoord4d",
326 "glTexCoord4dv",
327 "glTexCoord4f",
328 "glTexCoord4fv",
329 "glTexCoord4i",
330 "glTexCoord4iv",
331 "glTexCoord4s",
332 "glTexCoord4sv",
333 "glTexCoordPointer",
334 "glTexEnvf",
335 "glTexEnvfv",
336 "glTexEnvi",
337 "glTexEnviv",
338 "glTexGend",
339 "glTexGendv",
340 "glTexGenf",
341 "glTexGenfv",
342 "glTexGeni",
343 "glTexGeniv",
344 "glTexImage1D",
345 "glTexImage2D",
346 "glTexParameterf",
347 "glTexParameterfv",
348 "glTexParameteri",
349 "glTexParameteriv",
350 "glTexSubImage1D",
351 "glTexSubImage2D",
352 "glTranslated",
353 "glTranslatef",
354 "glVertex2d",
355 "glVertex2dv",
356 "glVertex2f",
357 "glVertex2fv",
358 "glVertex2i",
359 "glVertex2iv",
360 "glVertex2s",
361 "glVertex2sv",
362 "glVertex3d",
363 "glVertex3dv",
364 "glVertex3f",
365 "glVertex3fv",
366 "glVertex3i",
367 "glVertex3iv",
368 "glVertex3s",
369 "glVertex3sv",
370 "glVertex4d",
371 "glVertex4dv",
372 "glVertex4f",
373 "glVertex4fv",
374 "glVertex4i",
375 "glVertex4iv",
376 "glVertex4s",
377 "glVertex4sv",
378 "glVertexPointer",
379 "glViewport",
José Fonseca68ec4122011-02-20 11:25:25 +0000380
José Fonsecab87c2292011-10-09 14:56:16 +0100381 # GLX 1.3 and GLX_ARB_get_proc_address
382 "glXChooseVisual",
383 "glXCreateContext",
384 "glXDestroyContext",
385 "glXMakeCurrent",
386 "glXCopyContext",
387 "glXSwapBuffers",
388 "glXCreateGLXPixmap",
389 "glXDestroyGLXPixmap",
390 "glXQueryExtension",
391 "glXQueryVersion",
392 "glXIsDirect",
393 "glXGetConfig",
394 "glXGetCurrentContext",
395 "glXGetCurrentDrawable",
396 "glXWaitGL",
397 "glXWaitX",
398 "glXUseXFont",
399 "glXQueryExtensionsString",
400 "glXQueryServerString",
401 "glXGetClientString",
402 "glXGetCurrentDisplay",
403 "glXChooseFBConfig",
404 "glXGetFBConfigAttrib",
405 "glXGetFBConfigs",
406 "glXGetVisualFromFBConfig",
407 "glXCreateWindow",
408 "glXDestroyWindow",
409 "glXCreatePixmap",
410 "glXDestroyPixmap",
411 "glXCreatePbuffer",
412 "glXDestroyPbuffer",
413 "glXQueryDrawable",
414 "glXCreateNewContext",
415 "glXMakeContextCurrent",
416 "glXGetCurrentReadDrawable",
417 "glXQueryContext",
418 "glXSelectEvent",
419 "glXGetSelectedEvent",
José Fonseca68ec4122011-02-20 11:25:25 +0000420 "glXGetProcAddressARB",
421 "glXGetProcAddress",
José Fonsecab87c2292011-10-09 14:56:16 +0100422
423 # WGL
424 #"glDebugEntry",
425 "wglChoosePixelFormat",
426 "wglCopyContext",
427 "wglCreateContext",
428 "wglCreateLayerContext",
429 "wglDeleteContext",
430 "wglDescribeLayerPlane",
431 "wglDescribePixelFormat",
432 "wglGetCurrentContext",
433 "wglGetCurrentDC",
434 "wglGetDefaultProcAddress",
435 "wglGetLayerPaletteEntries",
436 "wglGetPixelFormat",
437 "wglGetProcAddress",
438 "wglMakeCurrent",
439 "wglRealizeLayerPalette",
440 "wglSetLayerPaletteEntries",
441 "wglSetPixelFormat",
442 "wglShareLists",
443 "wglSwapBuffers",
444 "wglSwapLayerBuffers",
445 "wglSwapMultipleBuffers",
446 "wglUseFontBitmapsA",
447 "wglUseFontBitmapsW",
448 "wglUseFontOutlinesA",
449 "wglUseFontOutlinesW",
450
José Fonsecac6b49ce2010-11-28 16:43:04 +0000451])
452
Chia-I Wue50c14b2011-11-03 12:24:53 +0800453# EGL 1.4
454public_symbols.update([
455 "eglBindAPI",
456 "eglBindTexImage",
457 "eglChooseConfig",
458 "eglCopyBuffers",
459 "eglCreateContext",
460 "eglCreatePbufferFromClientBuffer",
461 "eglCreatePbufferSurface",
462 "eglCreatePixmapSurface",
463 "eglCreateWindowSurface",
464 "eglDestroyContext",
465 "eglDestroySurface",
466 "eglGetConfigAttrib",
467 "eglGetConfigs",
468 "eglGetCurrentContext",
469 "eglGetCurrentDisplay",
470 "eglGetCurrentSurface",
471 "eglGetDisplay",
472 "eglGetError",
473 "eglGetProcAddress",
474 "eglInitialize",
475 "eglMakeCurrent",
476 "eglQueryAPI",
477 "eglQueryContext",
478 "eglQueryString",
479 "eglQuerySurface",
480 "eglReleaseTexImage",
481 "eglReleaseThread",
482 "eglSurfaceAttrib",
483 "eglSwapBuffers",
484 "eglSwapInterval",
485 "eglTerminate",
486 "eglWaitClient",
487 "eglWaitGL",
488 "eglWaitNative",
489])
José Fonsecac6b49ce2010-11-28 16:43:04 +0000490
José Fonseca68ec4122011-02-20 11:25:25 +0000491class GlDispatcher(Dispatcher):
492
493 def header(self):
José Fonseca68ec4122011-02-20 11:25:25 +0000494 print '#ifdef RETRACE'
José Fonseca3dabe542011-05-19 17:57:18 +0100495 print '# if defined(_WIN32)'
José Fonseca68ec4122011-02-20 11:25:25 +0000496 print '# define __getPrivateProcAddress(name) wglGetProcAddress(name)'
José Fonseca3dabe542011-05-19 17:57:18 +0100497 print '# elif defined(__APPLE__)'
498 print '# include <dlfcn.h>'
499 print '# define __getPrivateProcAddress(name) dlsym(RTLD_DEFAULT, name)'
José Fonseca68ec4122011-02-20 11:25:25 +0000500 print '# else'
501 print '# define __getPrivateProcAddress(name) glXGetProcAddressARB((const GLubyte *)(name))'
502 print '# endif'
José Fonseca68ec4122011-02-20 11:25:25 +0000503 print '#else /* !RETRACE */'
Chia-I Wue50c14b2011-11-03 12:24:53 +0800504 print '# if defined(TRACE_EGL)'
505 print '# define __getPublicProcAddress(name) __libegl_sym(name, true)'
506 print '# define __getPrivateProcAddress(name) __libegl_sym(name, false)'
507 print ' void * __libegl_sym(const char *symbol, bool pub);'
508 print '# elif defined(_WIN32)'
José Fonseca64e265d2011-08-25 15:15:42 +0100509 print ' PROC __getPublicProcAddress(LPCSTR lpProcName);'
José Fonseca68ec4122011-02-20 11:25:25 +0000510 print '# define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
511 print ' static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
512 print '# else'
José Fonsecac7b1c2a2011-06-11 12:26:39 +0100513 print '# define __getPublicProcAddress(name) __libgl_sym(name)'
514 print ' void * __libgl_sym(const char *symbol);'
José Fonseca43648602011-05-15 12:56:59 +0100515 print '# ifdef __APPLE__'
516 print '# define __getPrivateProcAddress(name) __getPublicProcAddress(name)'
517 print '# else'
518 print '# define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
519 print ' static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
520 print '# endif'
José Fonseca68ec4122011-02-20 11:25:25 +0000521 print '# endif'
José Fonseca68ec4122011-02-20 11:25:25 +0000522 print '#endif /* !RETRACE */'
523 print
524
525 def is_public_function(self, function):
José Fonseca3bcb33c2011-05-27 20:14:31 +0100526 return function.name in public_symbols or function.name.startswith('CGL')
José Fonsecac6b49ce2010-11-28 16:43:04 +0000527
528
529if __name__ == '__main__':
530 print
José Fonseca669b2002011-02-20 13:32:19 +0000531 print '#ifndef _GLPROC_HPP_'
532 print '#define _GLPROC_HPP_'
533 print
José Fonsecac6b49ce2010-11-28 16:43:04 +0000534 print '#include "glimports.hpp"'
535 print '#include "os.hpp"'
536 print
José Fonsecac6b49ce2010-11-28 16:43:04 +0000537 print
José Fonseca68ec4122011-02-20 11:25:25 +0000538 dispatcher = GlDispatcher()
539 dispatcher.header()
Chia-I Wue50c14b2011-11-03 12:24:53 +0800540 print '#if defined(TRACE_EGL)'
541 print
542 dispatcher.dispatch_api(eglapi)
543 print '#elif defined(_WIN32)'
José Fonseca68ec4122011-02-20 11:25:25 +0000544 print
545 dispatcher.dispatch_api(wglapi)
José Fonseca3dabe542011-05-19 17:57:18 +0100546 print '#elif defined(__APPLE__)'
547 dispatcher.dispatch_api(cglapi)
548 print '#else'
José Fonseca68ec4122011-02-20 11:25:25 +0000549 print
550 dispatcher.dispatch_api(glxapi)
José Fonseca3dabe542011-05-19 17:57:18 +0100551 print '#endif'
José Fonseca43648602011-05-15 12:56:59 +0100552 print
José Fonseca68ec4122011-02-20 11:25:25 +0000553 dispatcher.dispatch_api(glapi)
José Fonsecac6b49ce2010-11-28 16:43:04 +0000554 print
José Fonseca669b2002011-02-20 13:32:19 +0000555 print '#endif /* !_GLPROC_HPP_ */'
556 print