def eglQueryDevicesEXT(max_devices=10): # pylint: disable=invalid-name devices = (EGLDeviceEXT * max_devices)() num_devices = EGL.EGLint() success = _eglQueryDevicesEXT(max_devices, devices, num_devices) if success == EGL.EGL_TRUE: return [devices[i] for i in range(num_devices.value)] else: raise error.GLError(err=EGL.eglGetError(), baseOperation=eglQueryDevicesEXT, result=success)
def create_initialized_headless_egl_display(): """Creates an initialized EGL display directly on a device.""" for device in egl_get_devices(): display = egl.eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, device, None) if display != egl.EGL_NO_DISPLAY and egl.eglGetError( ) == egl.EGL_SUCCESS: # `eglInitialize` may or may not raise an exception on failure depending # on how PyOpenGL is configured. We therefore catch a `GLError` and also # manually check the output of `eglGetError()` here. try: initialized = egl.eglInitialize(display, None, None) except error.GLError: pass else: if initialized == egl.EGL_TRUE and egl.eglGetError( ) == egl.EGL_SUCCESS: return display return egl.EGL_NO_DISPLAY