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 '# define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
425 print ' static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
427 print '# define __getPublicProcAddress(name) __libgl_sym(name)'
428 print ' void * __libgl_sym(const char *symbol);'
429 print '# ifdef __APPLE__'
430 print '# define __getPrivateProcAddress(name) __getPublicProcAddress(name)'
432 print '# define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
433 print ' static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
436 print '#endif /* !RETRACE */'
439 def is_public_function(self, function):
440 return function.name in public_symbols or function.name.startswith('CGL')
443 if __name__ == '__main__':
445 print '#ifndef _GLPROC_HPP_'
446 print '#define _GLPROC_HPP_'
448 print '#include "glimports.hpp"'
449 print '#include "os.hpp"'
452 dispatcher = GlDispatcher()
454 print '#if defined(_WIN32)'
456 dispatcher.dispatch_api(wglapi)
457 print '#elif defined(__APPLE__)'
458 dispatcher.dispatch_api(cglapi)
461 dispatcher.dispatch_api(glxapi)
464 dispatcher.dispatch_api(glapi)
466 print '#endif /* !_GLPROC_HPP_ */'