Skip to content

Commit

Permalink
Merge pull request #41 from mtobiasm/nowindow
Browse files Browse the repository at this point in the history
RuntimeError "Cannot detect window"
  • Loading branch information
szabolcsdombi authored Nov 24, 2023
2 parents 672d695 + ae0f779 commit 07987f3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions _zengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,17 @@ def __init__(self):
if sys.platform.startswith("win"):
lib = ctypes.WinDLL("Opengl32.dll")
proc = ctypes.cast(lib.wglGetProcAddress, ctypes.CFUNCTYPE(ctypes.c_ulonglong, ctypes.c_char_p))
if not lib.wglGetCurrentContext():
raise RuntimeError('Cannot detect window with OpenGL support')

def loader(name):
return proc(name.encode()) or ctypes.cast(lib[name], ctypes.c_void_p).value

elif sys.platform.startswith("linux"):
lib = ctypes.CDLL("libGL.so")
proc = ctypes.cast(lib.glXGetProcAddress, ctypes.CFUNCTYPE(ctypes.c_ulonglong, ctypes.c_char_p))
if not lib.glxGetCurrentContext():
raise RuntimeError('Cannot detect window with OpenGL support')

def loader(name):
return proc(name.encode()) or ctypes.cast(lib[name], ctypes.c_void_p).value
Expand Down

0 comments on commit 07987f3

Please sign in to comment.