Creating a projection matrix in Qt OpenGL

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Creating a projection matrix in Qt OpenGL

Bugzilla from me@alandmoore.com
I'm working on a small demo of OpenGL in PyQt using the QOpenGLWidget.

My demo works except that whenever I translate it with a negative Z, the
back side of the drawing is getting cut off.  It seems like I must not
be setting the projection matrix correctly.

Below is my overridden resizeGL() method that sets up the matrix.  Am I
doing this correctly?


     def resizeGL(self, width, height):
         super().resizeGL(width, height)
         self.gl.glViewport(0, 0, self.width(), self.height())
         near_plane = 1
         far_plane = 200
         angle = 45
         aspect = self.width() / self.height()
         self.projection = qtg.QMatrix4x4()
         self.projection.setToIdentity()
         self.projection.perspective(
             angle, aspect, near_plane, far_plane)
         self.gl.glMatrixMode(self.gl.GL_PROJECTION)
         self.gl.glLoadIdentity()
         self.gl.glLoadMatrixd(self.projection.data())

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt