コード例 #1
0
    def __init__(self):
        super().__init__()
        # TODO: fix this placeholder:
        self._screens = [HeadlessScreen(self, 0, 0, 1920, 1080)]

        num_devices = egl.EGLint()
        eglext.eglQueryDevicesEXT(0, None, byref(num_devices))
        if num_devices.value > 0:
            headless_device = pyglet.options['headless_device']
            if headless_device < 0 or headless_device >= num_devices.value:
                 raise ValueError('Invalid EGL devide id: %d' % headless_device)
            devices = (eglext.EGLDeviceEXT * num_devices.value)()
            eglext.eglQueryDevicesEXT(num_devices.value, devices, byref(num_devices))
            self._display_connection  = eglext.eglGetPlatformDisplayEXT(eglext.EGL_PLATFORM_DEVICE_EXT, devices[headless_device], None)
        else:
            warning.warn('No device available for EGL device platform. Using native display type.')
            display = egl.EGLNativeDisplayType()
            self._display_connection = egl.eglGetDisplay(display)

        egl.eglInitialize(self._display_connection, None, None)
コード例 #2
0
    EGL_NONE: "EGL_NONE"
}

_api_types = {
    EGL_OPENGL_API: "EGL_OPENGL_API",
    EGL_OPENGL_ES_API: "EGL_OPENGL_ES_API",
    EGL_NONE: "EGL_NONE"
}

# Initialize a display:
display = libegl.EGLNativeDisplayType()
display_connection = libegl.eglGetDisplay(display)

majorver = libegl.EGLint()
minorver = libegl.EGLint()
result = libegl.eglInitialize(display_connection, majorver, minorver)
assert result == 1, "EGL Initialization Failed"
egl_version = majorver.value, minorver.value
print(f"EGL version: {egl_version}")

# Get the number of configs:
num_configs = libegl.EGLint()
config_size = libegl.EGLint()
result = libegl.eglGetConfigs(display_connection, None, config_size,
                              num_configs)
assert result == 1, "Failed to query Configs"

print("Number of configs available: ", num_configs.value)

# Choose a config:
config_attribs = (EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_BLUE_SIZE, 8,