IcePic
3rd March 2009, 07:18
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:
class Drawable {
virtual void render()=0;
}
class MyFirstObject : public Drawable {
void render() {
glBegin(GL_QUAD)
...
glEnd()
}
}
class GLWidget: public QGLWidget {
void paintGl() {
for(int i=0; i< drawables.size();i++) {
drawables.render();
}
}
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?
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:
class Drawable {
virtual void render()=0;
}
class MyFirstObject : public Drawable {
void render() {
glBegin(GL_QUAD)
...
glEnd()
}
}
class GLWidget: public QGLWidget {
void paintGl() {
for(int i=0; i< drawables.size();i++) {
drawables.render();
}
}
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?