I would like to render a 3D scene into different viewports. Those viewports are included in "subwindows" with their own menus like this:
Each viewport can be:
So we can have something like:
I believe it is better to embed each viewport into a Qt Widget containing my OpenGL widget (is that right?). So how can I render my 3D scene into several Qt OpenGL Widgets?
I believe it is better to embed each viewport into a Qt Widget containing my OpenGL widget (is that right?).So how can I render my 3D scene into several Qt OpenGL Widgets?
As described in QGlWidget's detailed description, besides overriding initializeGL and paintGL, you also need to override the resizeGL method. In the resizeGL method, you need to adjust the view port, and frustum.
After that, it is just a matter of creating and placing the widgets on the screen. They can be completely independent of each other, and you can set the frustum differently for each.
Since you want to share the opengl context between these widgets, take a look into OpenGL context sharing. To actually do it, you need to pass the OpenGL context object as the first parameter to the constructor of the QGLWidget.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With