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
41 # See http://www.opengl.org/registry/ABI/
42 public_symbols = set([
43 # GL 1.2 and ARB_multitexture
46 "glAreTexturesResident",
99 "glCopyTexSubImage1D",
100 "glCopyTexSubImage2D",
108 "glDisableClientState",
117 "glEnableClientState",
160 "glGetPolygonStipple",
168 "glGetTexLevelParameterfv",
169 "glGetTexLevelParameteriv",
170 "glGetTexParameterfv",
171 "glGetTexParameteriv",
186 "glInterleavedArrays",
251 "glPrioritizeTextures",
253 "glPushClientAttrib",
381 # GLX 1.3 and GLX_ARB_get_proc_address
388 "glXCreateGLXPixmap",
389 "glXDestroyGLXPixmap",
394 "glXGetCurrentContext",
395 "glXGetCurrentDrawable",
399 "glXQueryExtensionsString",
400 "glXQueryServerString",
401 "glXGetClientString",
402 "glXGetCurrentDisplay",
404 "glXGetFBConfigAttrib",
406 "glXGetVisualFromFBConfig",
414 "glXCreateNewContext",
415 "glXMakeContextCurrent",
416 "glXGetCurrentReadDrawable",
419 "glXGetSelectedEvent",
420 "glXGetProcAddressARB",
425 "wglChoosePixelFormat",
428 "wglCreateLayerContext",
430 "wglDescribeLayerPlane",
431 "wglDescribePixelFormat",
432 "wglGetCurrentContext",
434 "wglGetDefaultProcAddress",
435 "wglGetLayerPaletteEntries",
439 "wglRealizeLayerPalette",
440 "wglSetLayerPaletteEntries",
444 "wglSwapLayerBuffers",
445 "wglSwapMultipleBuffers",
446 "wglUseFontBitmapsA",
447 "wglUseFontBitmapsW",
448 "wglUseFontOutlinesA",
449 "wglUseFontOutlinesW",
454 public_symbols.update([
460 "eglCreatePbufferFromClientBuffer",
461 "eglCreatePbufferSurface",
462 "eglCreatePixmapSurface",
463 "eglCreateWindowSurface",
466 "eglGetConfigAttrib",
468 "eglGetCurrentContext",
469 "eglGetCurrentDisplay",
470 "eglGetCurrentSurface",
480 "eglReleaseTexImage",
491 class GlDispatcher(Dispatcher):
494 print '#ifdef RETRACE'
495 print '# if defined(_WIN32)'
496 print '# define __getPrivateProcAddress(name) wglGetProcAddress(name)'
497 print '# elif defined(__APPLE__)'
498 print '# include <dlfcn.h>'
499 print '# define __getPrivateProcAddress(name) dlsym(RTLD_DEFAULT, name)'
501 print '# define __getPrivateProcAddress(name) glXGetProcAddressARB((const GLubyte *)(name))'
503 print '#else /* !RETRACE */'
504 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)'
509 print ' PROC __getPublicProcAddress(LPCSTR lpProcName);'
510 print '# define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
511 print ' static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
513 print '# define __getPublicProcAddress(name) __libgl_sym(name)'
514 print ' void * __libgl_sym(const char *symbol);'
515 print '# ifdef __APPLE__'
516 print '# define __getPrivateProcAddress(name) __getPublicProcAddress(name)'
518 print '# define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
519 print ' static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
522 print '#endif /* !RETRACE */'
525 def is_public_function(self, function):
526 return function.name in public_symbols or function.name.startswith('CGL')
529 if __name__ == '__main__':
531 print '#ifndef _GLPROC_HPP_'
532 print '#define _GLPROC_HPP_'
534 print '#include "glimports.hpp"'
535 print '#include "os.hpp"'
538 dispatcher = GlDispatcher()
540 print '#if defined(TRACE_EGL)'
542 dispatcher.dispatch_api(eglapi)
543 print '#elif defined(_WIN32)'
545 dispatcher.dispatch_api(wglapi)
546 print '#elif defined(__APPLE__)'
547 dispatcher.dispatch_api(cglapi)
550 dispatcher.dispatch_api(glxapi)
553 dispatcher.dispatch_api(glapi)
555 print '#endif /* !_GLPROC_HPP_ */'