top of page
  • Writer's pictureNaijia Jin

ShadingViewer with PySide2 and PyOpenGL - (II)

As the next step, I want to make sure I can control the transformation of the cube renderred in the GLwindow.

Use timer to call UpdateGL every 16ms.

timer = QtCore.QTimer(self)
timer.timeout.connect(lambda: self.glWidget.updateGL())

Qt uses double-buffering automatically. Contexts are created with double-buffering enabled by default, and the swapBuffers() method is called after paintGL() returns.

This code creates a timer object using the QtCore library's QTimer class, which is a high-resolution timer that can be used to trigger events at a specified interval. The timer's interval is set to 16 milliseconds, which means that the timer will emit a "timeout" signal every 16 milliseconds. The timeout signal is connected to a lambda function that calls the updateGL() method on a "glWidget" object. Finally, the timer is started, which will cause it to emit the timeout signal repeatedly at the specified interval. This will cause the glWidget.updateGL() method to be called every 16 milliseconds, which will update the display of an OpenGL widget.

So I made the rotation and scale different groups. And hooked up the GLWindow rendering.

And the problem is, when I do anisotropic scaling(scale the x, y and z axis by different amount), then rotate it, the shape changes.

This is a problem related to the transformation order. The general order is scaling, rotation and translating.

I will come back to this later...

Now, I will try to switch the object gets rendered.



bottom of page