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 '# ifdef _WIN32'
415 print '# define __getPrivateProcAddress(name) wglGetProcAddress(name)'
417 print '# define __getPrivateProcAddress(name) glXGetProcAddressARB((const GLubyte *)(name))'
419 print '# define __abort() OS::Abort()'
420 print '#else /* !RETRACE */'
421 print '# ifdef _WIN32'
422 print '# define __getPrivateProcAddress(name) __wglGetProcAddress(name)'
423 print ' static inline PROC __stdcall __wglGetProcAddress(const char * lpszProc);'
425 print '# define __getPublicProcAddress(name) __dlsym(name)'
426 print ' static void * __dlsym(const char *symbol);'
427 print '# ifdef __APPLE__'
428 print '# define __getPrivateProcAddress(name) __getPublicProcAddress(name)'
430 print '# define __getPrivateProcAddress(name) __glXGetProcAddressARB((const GLubyte *)(name))'
431 print ' static inline __GLXextFuncPtr __glXGetProcAddressARB(const GLubyte * procName);'
434 print '# define __abort() Trace::Abort()'
435 print '#endif /* !RETRACE */'
438 def is_public_function(self, function):
439 return function.name in public_symbols
442 if __name__ == '__main__':
444 print '#ifndef _GLPROC_HPP_'
445 print '#define _GLPROC_HPP_'
447 print '#include "glimports.hpp"'
448 print '#include "os.hpp"'
451 dispatcher = GlDispatcher()
453 print '#ifdef _WIN32'
455 dispatcher.dispatch_api(wglapi)
456 print '#else /* !_WIN32 */'
458 dispatcher.dispatch_api(glxapi)
459 print '#endif /* !_WIN32 */'
461 print '#ifdef __APPLE__'
462 dispatcher.dispatch_api(cglapi)
463 print '#endif /* __APPLE__ */'
465 dispatcher.dispatch_api(glapi)
467 print '#endif /* !_GLPROC_HPP_ */'