[PySide] Is QOpenGLFunctions_3_3_Core supported in PySide2
Tom Goddard
goddard at sonic.net
Sat Dec 12 05:09:21 CET 2020
I am trying to figure out whether PySide2 offers an API for desktop OpenGL, e.g. 3.3 core profile. Currently I use PyOpenGL which is poorly maintained and would like to switch to using PySide2 OpenGL bindings if possible. Here is the Qt documentation of QOpenGLFunctions_3_3_Core that I would like to use from PySide2.
https://doc.qt.io/qt-5/qopenglfunctions-3-3-core.html <https://doc.qt.io/qt-5/qopenglfunctions-3-3-core.html>
Here are failed attempts. I am using PySide 15.1 on macOS 10.15.
1) First the class is not in QtGui which is where the live in C++ Qt
from PySide2.QtGui import QOpenGLFunctions_3_3_Core
-> import error, no such name
2) But there is an undocumented QtOpenGLFunctions module that has it
from PySide2.QtOpenGLFunctions import QOpenGLFunctions_3_3_Core as GL
and it contains the functions, e.g. GL.glClear but does not have the constants
GL.GL_COLOR_BUFFER_BIT
-> attribute error
dir(GL) -> shows only glXYZ functions not any GL_XYZ constants.
3) If I take my QOpenGLContext instance (that I currently use with PyOpenGL) qc and try to get the functions
GL = qc.versionFunctions()
it gives a QAbstractOpenGLFunctions instance with no opengl methods
GL.glClear
-> attribute error
There is a PySide2 bug report about that from Feb 2019 with no resolution
https://bugreports.qt.io/browse/PYSIDE-955 <https://bugreports.qt.io/browse/PYSIDE-955?jql=project%20=%20PYSIDE%20AND%20text%20~%20QOpenGLFunctions>
4) In PyQt5 approach 3 works
GL = qc.versionFunctions()
GL
-> <PyQt5._QOpenGLFunctions_4_1_Core.QOpenGLFunctions_4_1_Core at 0x14e325730>
and this module has glClear and GL_COLOR_BUFFER_BIT, seems to have what is needed although I have not tried using it.
Thanks for shedding any light on the using the desktop OpenGL API from PySide2.
Tom Goddard
ChimeraX molecular visualization developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20201211/2a6fbe4b/attachment.html>
More information about the PySide
mailing list