[Development] OpenGL sluggishness on Qt5 vs Qt4
mw_triad at users.sourceforge.net
Fri Nov 21 22:39:39 CET 2014
On 2014-11-21 05:22, Renaud wrote:
> I saw in your small example that you use "updateGL()", I suggest you to
> change it to "update()".
> It may help the performance on Qt5.
Hoo boy... I'm not sure why this would work better on Qt4 (see possible
idea, below), but updateGL() *IMMEDIATELY* calls your paintGL, i.e.
forces an immediate render to occur and don't return until the render is
completed. You *almost never* want to do that (if you're about to grab
the buffer is probably the only time you would). If you do that in a
mouse event handler, then (referring to your original observation) you
will indeed get a render for every mouse event that is processed.
update() on the other hand tells Qt that your widget needs to be
repainted "some time". In particular, "some time" generally means "when
you're done processing outstanding events". This will let you handle a
bunch of mouse events, do whatever changes you need, and then paint
(render) once all of them have been handled.
It may be that in Qt4 there is some coalescing of mouse events happening
that is not happening in Qt5.
At any rate, you will probably get much more similar performance with
update() vs. updateGL().
More information about the Development