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)
|