PDA

View Full Version : update() & updateGL()



rick_st3
21st June 2008, 11:01
hi.
What I wanted to know was, is there any difference between update() and updateGL()..? i mean i tried calling both of them in my code,and both of them were executing the paintGL() function...

wysota
22nd June 2008, 11:06
I think update() for QGLWidget is calling updateGL() (or the other way round), so you can use either of them.

rick_st3
23rd June 2008, 08:39
soo... if u can call a QGLWidget with a simple update() then what's the point in having an updateGL()...?? :confused:

wysota
23rd June 2008, 11:39
void QGLWidget::updateGL()
{
if (updatesEnabled())
glDraw();
}

void QGLWidget::paintEvent(QPaintEvent *)
{
if (updatesEnabled()) {
glDraw();
updateOverlayGL();
}
}

Do you see the difference?

spud
23rd June 2008, 11:55
updateGL() should be at least as fast, if not faster than update() since it bypasses the QWidget paint system with clipping, region updating and what have you.

A quick dump of the call stack (on windows) shows that update() has the following calling order:

> gltest.exe!GLWidget::paintGL() Line 18 C++
QtOpenGLd4.dll!QGLWidget::glDraw() Line 3111 C++
QtOpenGLd4.dll!QGLWidget::paintEvent(QPaintEvent * __formal=0x0012c354) Line 2898 C++
...
QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevic e * pdev=0x0012feb8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=3) Line 1212 + 0xd bytes C++
QtGuid4.dll!QWidget::repaint(const QRegion & rgn={...}) Line 1310 C++
QtGuid4.dll!qt_syncBackingStore(QRegion rgn={...}, QWidget * widget=0x0012feb0, bool recursive=true) Line 250 C++
QtGuid4.dll!QETWidget::translatePaintEvent(const tagMSG & msg={...}) Line 3111 + 0x2b bytes C++
...

whereas updateGL() gets down to business faster:


> gltest.exe!GLWidget::paintGL() Line 18 C++
QtOpenGLd4.dll!QGLWidget::glDraw() Line 3111 C++
QtOpenGLd4.dll!QGLWidget::updateGL() Line 2768 C++

(I left out the Signal/Slot messaging calls in both examples)

rick_st3
23rd June 2008, 11:56
@ wysota
errrr....no.... i can see an updateGL() function but no update()...!! :p

@ spud

the code didn't make that much sense to me but i think i got what it basically meant...!! thanks...

wysota
23rd June 2008, 12:39
@ wysota
errrr....no.... i can see an updateGL() function but no update()...!! :p

update() schedules a paintEvent.

rick_st3
23rd June 2008, 13:57
oh..!! had completely forgotten it...!! anyways thanx mate...!!