PDA

View Full Version : qGLWidget



mickey
23rd February 2006, 00:24
HI,
I have a question.
I'd like to show in my application 3 GLView that show different object...Do I code 3 different GL class or what?
Thanks

brcain
23rd February 2006, 00:32
Do you mean 3 different class instances?

mickey
23rd February 2006, 10:53
instances? it mean 3 different class declarations in 3 different header files that everyone will have an instance. If 3 widget must show 3 different objects I must to do this?

wysota
23rd February 2006, 12:03
No, why? :) If you tell your class how to draw three different scenes, you can use it multiple times.

mickey
23rd February 2006, 17:46
I thinks you says something so:

myWidget:: paintGL(){
.....
if (this== mywidget1) drawCube()
if (this== mywidget2) drawCube()
}
I have the way to retrieve myWidget1 pointer..but have you other idea?
thanks.

wysota
23rd February 2006, 22:27
More likely something like:


class MyGLWidget : public QGLWidget {
public:
MyGLWidget(int which, QWidget *p) : QGLWidget(p){ _which = which; }
void paintGL(){
switch(_which){
case 0: drawCube(); break;
case 1: drawCone(); break;
case 2: drawSphere(); break;
default: drawTeaPot();
}
}
// ...
private:
int _which;
};

mickey
24th February 2006, 00:52
sorry, where is the increment of wich parameter?

brcain
24th February 2006, 01:24
I didn't mean to complicate things by asking multiple class instances question.

Typically, I have a single scene graph instance ... passing the top-level scene graph node to each window. Each window is able to render different portions of the scene graph by using different cull masks. In this case I have multiple instances of a single class (something that renders a scene via OpenGL widget and a cull mask). Hope this makes more sense.

It seems to me this is the concept that wysota is trying to demonstrate. You can filter what you want to display based upon some filtering mechanism.

Cheers,
Ben

wysota
24th February 2006, 01:30
sorry, where is the increment of wich parameter?

What increment? You pass the value of "which" in the class constructor and based upon that the widget renders different scenes.