Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In our main function we instantiate this class and set the QGraphicsView parameters that are needed in our case. First of all the viewport needs to be a QGLWidget in order to do OpenGL rendering in our graphics scene. We use the SampleBuffers format specifier to enable multisample anti-aliasing in our rendering code.
- int main(int argc, char **argv)
- {
- QApplication app(argc, argv);
- GraphicsView view;
- view.setViewport(new QGLWidget(
- QGLFormat(QGL::SampleBuffers)));
- view.setViewportUpdateMode(
- QGraphicsView::FullViewportUpdate);
- view.setScene(new OpenGLScene);
- view.show();
- view.resize(1024, 768);
- return app.exec();
- }
- Next, we set the viewport update mode of the QGraphicsView to FullViewportUpdate as a QGLWidget cannot perform partial updates. Thus, we need to redraw everything whenever a part of the scene changes. We set as the scene an instance of our OpenGLScene class, a subclass of QGraphicsScene, and resize the view to a decent size.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement