[Qt-interest] custom OpenGL widget update blocks other Qt GUI rendering
Konstantin Tokarev
annulen at yandex.ru
Wed Feb 23 18:18:20 CET 2011
21.02.2011, 22:14, "Artem Kharitonyuk" <artemalive at gmail.com>:
> Konstantin Tokarev <annulen <at> yandex.ru> writes:
>
>> 21.02.2011, 14:35, "Artem Kharitonyuk" <artemalive <at> gmail.com>:
>>> Have the same problem.
>>> We implement gui for our raytracer with QT and we have preview window that
>>> renders using OpenGL (QGLWidget). Rendering is updated by the timer. For
>
> simple
>
>>> scenes everything is OK, but for really complex ones (> 10M triangles), when
>
> one
>
>>> frame takes > 100ms to render, we have a problem - open file dialog simply
>>> failed to draw itself - only some parts of it are appeared and than entire
>
> app
>
>>> stops responding.
>> You need to do OpenGL rendering in a separate thread
>
> Thanks, Konstantin!
>
> I've found another solution (In fact, I'm not sure that rendering should be done
> in separate thread, OpenGL functions are async, so it's not a problem).
>
> I simply added to the end of the function that is called by the timer and
> invokes "updateGL" method the following line: qApp->processEvents();
>
> void PreviewWindow::OnTimerEvent()
> {
> ... some other stuff
>
> updateGL();
>
> // Prevents GUI thread from stalling when frame rate is low.
> qApp->processEvents();
> }
It *will* hog CPU if frame rate is high, at least on Unix platforms
--
Regards,
Konstantin
More information about the Qt-interest-old
mailing list