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
def get_egl_display(self): return egl.eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, self.egl_dev, None)