[PyQt] Using OpenGL in PyQt on Windows

Phil Thompson phil at riverbankcomputing.com
Sat Mar 23 12:46:23 GMT 2019


On 20 Mar 2019, at 7:14 pm, alan moore <me at alandmoore.com> wrote:
> 
> I'm running windows 10 in a virtualbox machine with 3D drivers enabled.  From everything I've read, it *should* work with OpenGL.
> 
> 
> However, I cannot find any way to get access to OpenGL functions.  On Linux I can do the following:
> 
> ####### EXAMPLE
> 
> class OpenGLWidget(QOpenGLWidget):
> 
>     def initializeGL(self):
> 
>         # I can also specify a specific version using
> 
>         # QOpenGLVersionProfile on Linux
> 
>         self.gl = self.context().versionFunctions()
> 
>         print(type(self.gl))
> 
> ######### END OF EXAMPLE
> 
> 
> On Windows, I get an error printed to the console:
> 
>     versionFunctions: Not supported on OpenGL ES
> 
> And "self.gl" is None.

I hadn't realised that ES didn't support versioned functions.

> If I try to retrieve the functions self.context().functions(), I'm told that:
> 
>     QOpenGLContext object has no attribute 'functions'
> 
> 
> If I try to directly create a QOpenGLFunctions object, I'm told that it doesn't exist (It should be part of QtGui according to the Qt docs, but doesn't exist on Windows or Linux).

The Qt docs describe the C++ API, not the PyQt API.

functions() isn't implemented in PyQt because it is recommended to use direct inheritance and inheritance of multiple wrapped classes is not supported.

> I'm stumped.  How do I get my OpenGL functions object on Windows?

As I've said many times before, I know almost nothing about OpenGL and need an expert to help ensuring the OpenGL support is properly usable - but nobody has ever stepped up.

Phil


More information about the PyQt mailing list