Advertisement
Guest User

Untitled

a guest
Jun 30th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. 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.
  2.  
  3. int main(int argc, char **argv)
  4. {
  5. QApplication app(argc, argv);
  6.  
  7. GraphicsView view;
  8. view.setViewport(new QGLWidget(
  9. QGLFormat(QGL::SampleBuffers)));
  10. view.setViewportUpdateMode(
  11. QGraphicsView::FullViewportUpdate);
  12. view.setScene(new OpenGLScene);
  13. view.show();
  14.  
  15. view.resize(1024, 768);
  16. return app.exec();
  17. }
  18. 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