PyQt5, OpenGL, where to start, minimal example code?

Phil Thompson phil at riverbankcomputing.com
Mon Oct 3 04:29:59 EDT 2016


On 3 Oct 2016, at 4:29 am, John Ladasky <john_ladasky at sbcglobal.net> wrote:
> 
> On Sunday, October 2, 2016 at 7:21:15 PM UTC-7, blue wrote:
>> You have here a PyQt5 Reference Guide http://pyqt.sourceforge.net/Docs/PyQt5/index.html
>> Some example can be found here 4 and 5 http://codeprogress.com/python/libraries/pyqt/
> 
> That's a nice page of examples, but there are no OpenGL examples.
> 
>> Support for OpenGL http://pyqt.sourceforge.net/Docs/PyQt5/opengl.html told us:
>> 
>> When compiled against Qt v5.1 or later, PyQt5 implements a set of either desktop QOpenGL bindings or OpenGL ES v2 bindings depending on how Qt was configured. This removes the dependency on any third-party OpenGL bindings such as PyOpenGL.
>> 
>> At the moment the desktop bindings are for OpenGL v2.0 and are mostly complete. Other versions will be added in later releases. If there are calls which you need, but are currently unsupported, then please ask for the support to be added.
> 
> I found that page many days ago.  I am not sure whether OpenGL 4.5, which is what Ubuntu installed for me, is an extension of OpenGL ES v2, or something completely different.
> 
> PyQt5 seems to be at least nominally aware of recent versions of OpenGL, and it knows that I have version 4.5 -- since my program went looking for a module called "QOpenGLFunctions_4_5_Compatibility".  On this page...
> 
> http://doc.qt.io/qt-5/qtgui-module.html
> 
> ...the Qt5 QTGui documentation lists a plethora of functions to retrieve OpenGL "specifications" and "compatibility profiles", ranging from OpenGL 1.0 through 4.5.
> 
> Note, these are not PyQt docs, they are for Qt.  I have been sometimes frustrated by the fact that the PyQt modules do not appear to have a one-to-one mapping with the hierarchy of Qt itself.
> 
>> Obtaining an object that implements the bindings for a particular OpenGL version and profile is done in the same way as it is done from C++, i.e. by calling versionFunctions(). In addition, the bindings object also contains attributes corresponding to all of the OpenGL constants.
> 
> And as you can see: trying to call versionFunctions() is exactly where my program failed.

Try passing a QOpenGLVersionProfile object to versionFunctions() that has a version set to one supported by PyQt.

Phil


More information about the Python-list mailing list