-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglfw_platform.py
50 lines (45 loc) · 1.46 KB
/
glfw_platform.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''
Minimal GLFW platform for PyOpenGL. This looks up functions through GLFW
without any knowledge of the underlying platform.
'''
import ctypes
import glfw
from OpenGL.platform import baseplatform
class GLFWPlatform(baseplatform.BasePlatform):
"""GLFW platform"""
GLES1 = None
GLES2 = None
GLES3 = None
GL = None
OpenGL = None
# GLU, GLUT, GLE cannot be looked up through this platform.
DEFAULT_FUNCTION_TYPE = staticmethod(ctypes.CFUNCTYPE)
def constructFunction(self,
functionName, dll,
resultType=ctypes.c_int, argTypes=(),
doc = None, argNames = (),
extension = None,
deprecated = False,
module = None,
force_extension = False,
error_checker = None,
):
return super().constructFunction(
functionName, dll,
resultType, argTypes,
doc, argNames,
extension,
deprecated,
module,
True, # Force lookup through getExtensionProcedure instead of cdll
None)
def getExtensionProcedure(self, procname):
'''
Look up function pointer for client API function.
'''
return glfw.get_proc_address(procname.decode())
def GetCurrentContext(self):
'''
Return context. Must be a hashable value, so take the address.
'''
return ctypes.cast(glfw.get_current_context(), ctypes.c_void_p).value