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.
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
40 # See http://www.opengl.org/registry/ABI/
41 public_symbols = set([
44 "glAreTexturesResident",
97 "glCopyTexSubImage1D",
98 "glCopyTexSubImage2D",
107 "glDisableClientState",
116 "glEnableClientState",
159 "glGetPolygonStipple",
167 "glGetTexLevelParameterfv",
168 "glGetTexLevelParameteriv",
169 "glGetTexParameterfv",
170 "glGetTexParameteriv",
185 "glInterleavedArrays",
250 "glPrioritizeTextures",
252 "glPushClientAttrib",
379 "wglChoosePixelFormat",
382 "wglCreateLayerContext",
384 "wglDescribeLayerPlane",
385 "wglDescribePixelFormat",
386 "wglGetCurrentContext",
388 "wglGetDefaultProcAddress",
389 "wglGetLayerPaletteEntries",
393 "wglRealizeLayerPalette",
394 "wglSetLayerPaletteEntries",
398 "wglSwapLayerBuffers",
399 "wglSwapMultipleBuffers",
400 "wglUseFontBitmapsA",
401 "wglUseFontBitmapsW",
402 "wglUseFontOutlinesA",
403 "wglUseFontOutlinesW",
405 "glXGetProcAddressARB",
410 class GlDispatcher(Dispatcher):
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)'
420 print '# define __getPrivateProcAddress(name) glXGetProcAddressARB((const GLubyte *)(name))'
422 print '#else /* !RETRACE */'
423 print '# ifdef _WIN32'
424 print ' PROC __getPublicProcAddress(LPCSTR lpProcName);'
425 print '# define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
426 print ' static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
428 print '# define __getPublicProcAddress(name) __libgl_sym(name)'
429 print ' void * __libgl_sym(const char *symbol);'
430 print '# ifdef __APPLE__'
431 print '# define __getPrivateProcAddress(name) __getPublicProcAddress(name)'
433 print '# define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
434 print ' static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
437 print '#endif /* !RETRACE */'
440 def is_public_function(self, function):
441 return function.name in public_symbols or function.name.startswith('CGL')
444 if __name__ == '__main__':
446 print '#ifndef _GLPROC_HPP_'
447 print '#define _GLPROC_HPP_'
449 print '#include "glimports.hpp"'
450 print '#include "os.hpp"'
453 dispatcher = GlDispatcher()
455 print '#if defined(_WIN32)'
457 dispatcher.dispatch_api(wglapi)
458 print '#elif defined(__APPLE__)'
459 dispatcher.dispatch_api(cglapi)
462 dispatcher.dispatch_api(glxapi)
465 dispatcher.dispatch_api(glapi)
467 print '#endif /* !_GLPROC_HPP_ */'