Hello!

I have a problem concerning the design of a opengl/qt programm.

I create a subclass from QGLWidget and overwrite the paintGl-method to do my renderstuff.
My subclass should have a vector with drawables. Drawables is a abstract class with a renderfunction. In this function every subclass from drawable should do their opengl stuff.
Something like this:

Qt Code:
  1. class Drawable {
  2. virtual void render()=0;
  3. }
  4.  
  5. class MyFirstObject : public Drawable {
  6.  
  7. void render() {
  8. glBegin(GL_QUAD)
  9. ...
  10. glEnd()
  11. }
  12. }
  13.  
  14. class GLWidget: public QGLWidget {
  15.  
  16. void paintGl() {
  17. for(int i=0; i< drawables.size();i++) {
  18. drawables.render();
  19. }
  20. }
To copy to clipboard, switch view to plain text mode 

The problem is, that i don't have an active opengl context in my drawables and so the opengl functions don't work. How can i solve this problem?