@@ -261,6 +261,8 @@ class DefaultLoader:
261261 def __init__ (self ):
262262 import ctypes
263263
264+ from ctypes .util import find_library
265+
264266 def funcptr (lib , name ):
265267 return ctypes .cast (getattr (lib , name , 0 ), ctypes .c_void_p ).value or 0
266268
@@ -275,7 +277,11 @@ def loader(name):
275277
276278 elif sys .platform .startswith ('linux' ):
277279 try :
278- lib = ctypes .CDLL ('libEGL.so' )
280+ libegl = find_library ('EGL' )
281+ if libegl is None :
282+ raise RuntimeError ("Cannot find OpenGL support library libEGL" )
283+
284+ lib = ctypes .CDLL (libegl )
279285 proc = ctypes .cast (lib .eglGetProcAddress , ctypes .CFUNCTYPE (ctypes .c_ulonglong , ctypes .c_char_p ))
280286 if not lib .eglGetCurrentContext ():
281287 raise RuntimeError ('Cannot detect window with OpenGL support' )
@@ -284,7 +290,11 @@ def loader(name):
284290 return proc (name .encode ())
285291
286292 except :
287- lib = ctypes .CDLL ('libGL.so' )
293+ libgl = find_library ('GL' )
294+ if libgl is None :
295+ raise RuntimeError ("Cannot find OpenGL support library libGL" )
296+
297+ lib = ctypes .CDLL (libgl )
288298 proc = ctypes .cast (lib .glXGetProcAddress , ctypes .CFUNCTYPE (ctypes .c_ulonglong , ctypes .c_char_p ))
289299 if not lib .glXGetCurrentContext ():
290300 raise RuntimeError ('Cannot detect window with OpenGL support' ) from None
0 commit comments