PDA

View Full Version : paintGL() and initializeGL() help



mickey
11th February 2006, 19:42
HI,
my application consists of 3 widget; in the MultipleView I draw myWidget2 and 3;in PerspectiveView myWidget1; application starts with Perspective view; I have insert some printf("...") inside painGL an initializeGL()
and I see that they are run in this order (when I launch program):
initializeGL()
paintGL()
paintGL()
paintGL()
initializeGL()
initializeGL()


void MainForm::changeView(QAction* action) {
if ( action == perspectiveViewAction ) {
WidgetStack->raiseWidget( PerspectiveView );
}
else if ( action == multipleViewAction ) {
WidgetStack->raiseWidget( MultipleView );
}
}
I don't understand why the last 2 paintGL are running before the 2 initializeGL(). Is it right?
And when I call changeView(), starts sometimes 5 paintGL() other times only two....
Thanks

yogeshm02
12th February 2006, 14:36
HI,
.... I see that they are run in this order (when I launch program):
initializeGL()
paintGL()
paintGL()
paintGL()
initializeGL()
initializeGL()
.
.
.
I don't understand why the last 2 paintGL are running before the 2 initializeGL(). Is it right?

initializeGL is always called first. Are you sure last 2 paintGL which you are refering to belong to other two widgets, they could have been posted by widget1? My question may look silly, but it can be true.

mickey
12th February 2006, 22:31
last 2 paintGL() belong to the first widget? I don't know reason....And Are the last two initializeGL() called from widget2 and widget3? But When does initaliazedGL() start? (when a widget must be painted?)
When Are initalizeGL() and PaintGL() always bind?
Thanks

jacek
12th February 2006, 22:46
last 2 paintGL() belong to the first widget? I don't know reason....And Are the last two initializeGL() called from widget2 and widget3?
Change those printf statements to make them output something that will allow you to distinguish between those two widgets (for example the value of "this").

mickey
13th February 2006, 10:56
OK! My output is this:

initalizeGL() widget1
paintGL() widget1
paintGL() widget1
paintGL() widget1

initalizeGL() widget2
initalizeGL() widget3
But there aren't reasons (for my humble opinion) for the last 2 paintGL(). Widget1 drawn three time? I have comment all code of paintGL() and 3 paintGL() starts again!!!
The last two initialize I think is right(?!): initialize context but don't draw (application start with widget1)

wysota
13th February 2006, 11:48
I'm sorry but is it that bad that the paintGL() routine is called one or two times more?

mickey
13th February 2006, 11:53
I don't know! Is it OK? I'd like to know the reasons that calls paintGL() 3 times; when I changeView (see code post before) widget2 and widget3 are called 2 times for widget (2 widgets = 4 paintGL())....

wysota
13th February 2006, 12:08
Probably the widgets just need to be redrawn. It is difficult to say without seeing your code.

mickey
14th February 2006, 20:11
I have comment all PaintGL() and any updateGL(). PaintGL() starts three times for the first widget.....Can be any problem from Qt Designer? (when I designed MyWidget class)

mickey
20th February 2006, 00:11
HI,
I see that for the widget 1 happen (in this order):

initializeGL()
resizeGL()
resizeGL()
paintGL()
resizeGL()
resizeGL()
paintGL()
paintGL()

This is for a widget! Is this strange?


void MyWidget::resizeGL( int w, int h )
{
cout << "resize" << this << endl;
// setup viewport, projection etc.:
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
GLdouble ratio=((GLdouble)w)/(GLdouble)h;
gluPerspective(45,ratio,3,40);
glViewport (0, 0, (GLdouble) w, (GLdouble) h);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
}

wysota
20th February 2006, 14:30
The number of "paintGL" calls doesn't really depend on the style of coding you take, but on the environment of the widget. If it becomes obscured, it needs to repaint itself, so it calls paintGL.

mickey
20th February 2006, 14:35
In wich sense "obscured"?

wysota
20th February 2006, 14:43
In wich sense "obscured"?

I.e. if you move some other window over it.

mickey
20th February 2006, 17:00
3 paintGL() are called when app starts. there are no any window on my app.

I insert a getchar() at begin of paintGL(). 1st paint() make nothing, second paint draw my app (windows, toolbar, toolbox) with myWidgetGL black! 3st paint fill myWidgetGL with the objects of the scene....

mickey
26th February 2006, 18:15
Hi,
I know only now that the problem of multiple start of PaintGL() is my ToolBox. If I delete it paintGL() not starts three times instead of only one!
What I can do? Idesinger myWidget and myToolBox from designerover a WidgetStack...