File: glinfo.py

package info (click to toggle)
python-pyqtgraph 0.13.7-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 8,068 kB
  • sloc: python: 54,043; makefile: 129; ansic: 40; sh: 2
file content (46 lines) | stat: -rw-r--r-- 1,192 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
41
42
43
44
45
46
import importlib

from ..Qt import QT_LIB, QtGui

GL_VENDOR = 7936
GL_RENDERER = 7937
GL_VERSION = 7938


def print_version(funcs):
    glGetString = funcs.glGetString
    print('VENDOR:', glGetString(GL_VENDOR))
    print('RENDERER:', glGetString(GL_RENDERER))
    print('VERSION:', glGetString(GL_VERSION))


def print_extensions(ctx):
    extensions = sorted([ext.data().decode() for ext in ctx.extensions()])
    print("Extensions:")
    for ext in extensions:
        print(f"   {ext}")


app = QtGui.QGuiApplication([])
surf = QtGui.QOffscreenSurface()
surf.create()
ctx = QtGui.QOpenGLContext()
ctx.create()
ctx.makeCurrent(surf)

if QT_LIB == 'PySide2':
    funcs = ctx.functions()
elif QT_LIB == 'PyQt5':
    profile = QtGui.QOpenGLVersionProfile()
    profile.setVersion(2, 0)
    funcs = ctx.versionFunctions(profile)
elif QT_LIB in ['PyQt6', 'PySide6']:
    QtOpenGL = importlib.import_module(f'{QT_LIB}.QtOpenGL')
    profile = QtOpenGL.QOpenGLVersionProfile()
    profile.setVersion(2, 0)
    funcs_factory = QtOpenGL.QOpenGLVersionFunctionsFactory()
    funcs = funcs_factory.get(profile, ctx)

print('isOpenGLES:', ctx.isOpenGLES())
print_version(funcs)
print_extensions(ctx)