1 ##########################################################################
3 # Copyright 2010 VMware, Inc.
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:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
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
24 ##########################################################################/
27 """Generated an header, glproc.hpp, which does pretty much what GLEW does, but
28 covers all the functions we support.
32 import specs.stdapi as stdapi
33 from dispatch import Dispatcher
34 from specs.glapi import glapi
35 from specs.glxapi import glxapi
36 from specs.wglapi import wglapi
37 from specs.cglapi import cglapi
38 from specs.eglapi import eglapi
39 from specs.glesapi import glesapi
42 # See http://www.opengl.org/registry/ABI/
43 public_symbols = set([
44 # GL 1.2 and ARB_multitexture
47 "glAreTexturesResident",
100 "glCopyTexSubImage1D",
101 "glCopyTexSubImage2D",
109 "glDisableClientState",
118 "glEnableClientState",
161 "glGetPolygonStipple",
169 "glGetTexLevelParameterfv",
170 "glGetTexLevelParameteriv",
171 "glGetTexParameterfv",
172 "glGetTexParameteriv",
187 "glInterleavedArrays",
252 "glPrioritizeTextures",
254 "glPushClientAttrib",
382 # GLX 1.3 and GLX_ARB_get_proc_address
389 "glXCreateGLXPixmap",
390 "glXDestroyGLXPixmap",
395 "glXGetCurrentContext",
396 "glXGetCurrentDrawable",
400 "glXQueryExtensionsString",
401 "glXQueryServerString",
402 "glXGetClientString",
403 "glXGetCurrentDisplay",
405 "glXGetFBConfigAttrib",
407 "glXGetVisualFromFBConfig",
415 "glXCreateNewContext",
416 "glXMakeContextCurrent",
417 "glXGetCurrentReadDrawable",
420 "glXGetSelectedEvent",
421 "glXGetProcAddressARB",
426 "wglChoosePixelFormat",
429 "wglCreateLayerContext",
431 "wglDescribeLayerPlane",
432 "wglDescribePixelFormat",
433 "wglGetCurrentContext",
435 "wglGetDefaultProcAddress",
436 "wglGetLayerPaletteEntries",
440 "wglRealizeLayerPalette",
441 "wglSetLayerPaletteEntries",
445 "wglSwapLayerBuffers",
446 "wglSwapMultipleBuffers",
447 "wglUseFontBitmapsA",
448 "wglUseFontBitmapsW",
449 "wglUseFontOutlinesA",
450 "wglUseFontOutlinesW",
455 public_symbols.update([
461 "eglCreatePbufferFromClientBuffer",
462 "eglCreatePbufferSurface",
463 "eglCreatePixmapSurface",
464 "eglCreateWindowSurface",
467 "eglGetConfigAttrib",
469 "eglGetCurrentContext",
470 "eglGetCurrentDisplay",
471 "eglGetCurrentSurface",
481 "eglReleaseTexImage",
492 class GlDispatcher(Dispatcher):
495 print '#ifdef RETRACE'
496 print '# if defined(_WIN32)'
497 print '# define __getPrivateProcAddress(name) wglGetProcAddress(name)'
498 print '# elif defined(__APPLE__)'
499 print '# include <dlfcn.h>'
500 print '# define __getPrivateProcAddress(name) dlsym(RTLD_DEFAULT, name)'
502 print '# define __getPrivateProcAddress(name) glXGetProcAddressARB((const GLubyte *)(name))'
504 print '#else /* !RETRACE */'
505 print '# if defined(TRACE_EGL)'
506 print '# define __getPublicProcAddress(name) __libegl_sym(name, true)'
507 print '# define __getPrivateProcAddress(name) __libegl_sym(name, false)'
508 print ' void * __libegl_sym(const char *symbol, bool pub);'
509 print '# elif defined(_WIN32)'
510 print ' PROC __getPublicProcAddress(LPCSTR lpProcName);'
511 print '# define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
512 print ' static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
514 print '# define __getPublicProcAddress(name) __libgl_sym(name)'
515 print ' void * __libgl_sym(const char *symbol);'
516 print '# ifdef __APPLE__'
517 print '# define __getPrivateProcAddress(name) __getPublicProcAddress(name)'
519 print '# define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
520 print ' static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
523 print '#endif /* !RETRACE */'
526 def is_public_function(self, function):
527 return function.name in public_symbols or function.name.startswith('CGL')
530 if __name__ == '__main__':
532 print '#ifndef _GLPROC_HPP_'
533 print '#define _GLPROC_HPP_'
535 print '#include "glimports.hpp"'
536 print '#include "os.hpp"'
539 dispatcher = GlDispatcher()
541 print '#if defined(TRACE_EGL)'
543 dispatcher.dispatch_api(eglapi)
544 print '#elif defined(_WIN32)'
546 dispatcher.dispatch_api(wglapi)
547 print '#elif defined(__APPLE__)'
548 dispatcher.dispatch_api(cglapi)
551 dispatcher.dispatch_api(glxapi)
554 dispatcher.dispatch_api(glapi)
556 dispatcher.dispatch_api(glesapi)
559 print '#endif /* !_GLPROC_HPP_ */'