1 ##########################################################################
3 # Copyright 2008-2009 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 ##########################################################################/
30 libgl.functions = basic_functions(DllFunction)
33 class GlxGetProcAddressFunction(DllFunction):
35 def __init__(self, type, name, args):
36 DllFunction.__init__(self, type, name, args)
40 for function in self.functions:
42 DllFunction.wrap_decl(self)
45 for function in self.functions:
47 DllFunction.wrap_impl(self)
49 def post_call_impl(self):
51 for function in self.functions:
52 ptype = function.pointer_type()
53 pvalue = function.pointer_value()
54 print ' if(!strcmp("%s", (const char *)procName)) {' % function.name
55 print ' %s = (%s)result;' % (pvalue, ptype)
56 print ' result = (void(*)())&%s;' % function.name;
61 PROC = Opaque("__GLXextFuncPtr")
63 glXgetprocaddress = GlxGetProcAddressFunction(PROC, "glXGetProcAddress", [(Alias("const GLubyte *", String), "procName")])
64 libgl.functions.append(glXgetprocaddress)
66 class GlxFunction(Function):
68 def __init__(self, type, name, args, call = '', **kwargs):
69 Function.__init__(self, type, name, args, call=call, **kwargs)
71 def get_true_pointer(self):
72 ptype = self.pointer_type()
73 pvalue = self.pointer_value()
74 print ' if(!%s)' % (pvalue,)
77 glXgetprocaddress.functions += extended_functions(GlxFunction)
80 if __name__ == '__main__':
82 print '#include <stdlib.h>'
83 print '#include <string.h>'
84 print '#include <dlfcn.h>'
85 print '#include <X11/Xlib.h>'
86 print '#include <GL/gl.h>'
87 print '#include <GL/glext.h>'
88 print '#include <GL/glx.h>'
89 print '#include <GL/glxext.h>'
91 print '#include "log.hpp"'
92 print '#include "glhelpers.hpp"'