File: check_egl_device_enumeration.py

package info (click to toggle)
pyopengl 3.1.10%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,024 kB
  • sloc: python: 108,056; sh: 13; makefile: 8
file content (40 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env python
import logging

# import os_egl
from OpenGL.EGL import *
from OpenGL.EGL.EXT.device_enumeration import eglQueryDevicesEXT

log = logging.getLogger(__name__)


def main():
    devices = (EGLDeviceEXT * 10)()
    count = EGLint()
    major, minor = EGLint(), EGLint()
    if not eglQueryDevicesEXT:
        raise RuntimeError("No egl query devices extension available")
    if eglQueryDevicesEXT(10, devices, count):
        log.info("%s devices enumerated", count)
        for i, device in enumerate(devices[: count.value]):
            log.info("Describing device #%d: %s", i, device)
            display = eglGetDisplay(device)
            try:
                if not eglInitialize(display, major, minor):
                    log.info("Could not initialise, skipping")
                    continue
            except EGLError as err:
                log.warning("Unable to initialise EGL for display %d: %s", i, err)
            log.info("Display #%d, Version %s.%s", i, major.value, minor.value)
            for key in [
                EGL_VENDOR,
            ]:
                log.info(" Vendor: %s", eglQueryString(display, key))
            log.info("Finished device #%d", i)
    else:
        log.warning("Unable to query devices")


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    main()