[PyQt] glGetFloatv crashes application

Phil Thompson phil at riverbankcomputing.com
Tue Feb 7 13:36:56 GMT 2017


On 6 Feb 2017, at 10:33 pm, Jonatan Magnusson <jonatan.magnusson at gmail.com> wrote:
> 
> 
> 
> Den 2017-02-06 kl. 22:42, skrev Phil Thompson:
> 
>> I would describe the OpenGL support as very immature. Can you send me a short, complete example that demonstrates the problem?
> 
> Sure!
> 
> 
> import sys
> from PyQt5.QtWidgets import QWidget, QOpenGLWidget, QApplication, QHBoxLayout
> from PyQt5.QtCore import QSize
> 
> class GLView(QOpenGLWidget):
>    def minimumSizeHint(self):
>        return QSize(50, 50)
> 
>    def sizeHint(self):
>        return QSize(400, 400)
> 
>    def initializeGL(self):
>        self.gl = self.context().versionFunctions()
>        self.gl.initializeOpenGLFunctions()
> 
>    def paintGL(self):
>        self.gl.glLoadIdentity()
>        self.gl.glTranslatef(1, 2, 3)
>        print("before")
>        m = self.gl.glGetFloatv(self.gl.GL_MODELVIEW_MATRIX)
>        print("after")
>        print(str(m))
> 
>    def resizeGL(self, width, height):
>        self.gl.glViewport(0, 0, width, height)
> 
> class TestWindow(QWidget):
>    def __init__(self):
>        super(TestWindow, self).__init__()
>        layout = QHBoxLayout()
>        layout.addWidget(GLView())
>        self.setLayout(layout)
> 
> app = QApplication(sys.argv)
> window = TestWindow()
> window.show()
> sys.exit(app.exec_())

The problem is that glGetFloatv() doesn't know about GL_MODELVIEW_MATRIX (and that it returns 16 values). Is there a definitive list somewhere of the names that can be queried and the versions of OpenGL they apply to?

Phil


More information about the PyQt mailing list