4
from ctypes.util import find_library
5
from ctypes.test import is_resource_enabled
7
if sys.platform == "win32":
8
lib_gl = find_library("OpenGL32")
9
lib_glu = find_library("Glu32")
11
elif sys.platform == "darwin":
12
lib_gl = lib_glu = find_library("OpenGL")
15
lib_gl = find_library("GL")
16
lib_glu = find_library("GLU")
17
lib_gle = find_library("gle")
19
## print, for debugging
20
if is_resource_enabled("printing"):
21
if lib_gl or lib_glu or lib_gle:
22
print("OpenGL libraries:")
23
for item in (("GL", lib_gl),
29
# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
30
class Test_OpenGL_libs(unittest.TestCase):
32
self.gl = self.glu = self.gle = None
34
self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
36
self.glu = CDLL(lib_glu, RTLD_GLOBAL)
39
self.gle = CDLL(lib_gle)
51
self.glu.gluBeginCurve
56
self.gle.gleGetJoinStyle
58
##if os.name == "posix" and sys.platform != "darwin":
60
## # On platforms where the default shared library suffix is '.so',
61
## # at least some libraries can be loaded as attributes of the cdll
62
## # object, since ctypes now tries loading the lib again
63
## # with '.so' appended of the first try fails.
65
## # Won't work for libc, unfortunately. OTOH, it isn't
66
## # needed for libc since this is already mapped into the current
69
## # On MAC OSX, it won't work either, because dlopen() needs a full path,
70
## # and the default suffix is either none or '.dylib'.
72
## class LoadLibs(unittest.TestCase):
73
## def test_libm(self):
77
## sqrt.argtypes = (c_double,)
78
## sqrt.restype = c_double
79
## self.assertEqual(sqrt(2), math.sqrt(2))
81
if __name__ == "__main__":