[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Creating a projection matrix in Qt OpenGL
From:       alan moore <me () alandmoore ! com>
Date:       2019-03-20 3:42:23
Message-ID: ab936132-7923-a636-a3d3-5ccb320e850b () alandmoore ! com
[Download RAW message or body]

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    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic