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