gl engine and QT widget

Started by
13 comments, last by Genkaku 13 years, 8 months ago
Hy.
I use a opengl engine and i would integrate it in a qt widget.
The engine have an infinite loop for drawing items in a scene.
I think to use an opengl qt widget for visualize some 3d data.
My problem is that all the drawing is done in this infinite loop , how i can insert all in the onpaint function of the opengl widget if there are two infinite loop ?The on paint of the qt widget and the ondraw of the engine?
advice?
Thanks.
Advertisement
Do not use a loop for updating the GL widget. Use a timer, and have the timer call updateGL on you widget once every time the timer hits....
sorry , but i'm not understand at all.
Use a QTimer and connect the triggered() signal off the timer to your render function. Set the timer for something like every 16ms and to loop.

cheers,

Bob

[size="3"]Halfway down the trail to Hell...
OK, I understand that to elegantly use QT with OpenGL I'd have to connect QTTimer to my draw() function. That's logical.
But what can I do to call lotsOfMath() as often as possible (that is: to call it as soon as previous one has just ended).

The thing is I would like to write a simulation in which some math stuff and collision detection will take place. And it would be nice if I could call sim() "continuously" and call draw() every 50th frame for example.

When using SDL it is quite straightforward, but with QT?...
Have you tried using a timer with a 0ms timeout?
I'll try it, but that would require to have something like:

if (!running) {

//my stuff
}

Hmmm... yes, it certainly is an idea to try. Thanks.
Quote:Original post by Genkaku
I'll try it, but that would require to have something like:

if (!running) {

//my stuff
}

Hmmm... yes, it certainly is an idea to try. Thanks.


I can't follow you. Why would you need that?

*edit*
If you want to pause your application, then you can simply stop the timer, until it continues, if you meant that...
It would be necessary to not run sim() multiple times at once.
I'm still unsure what you mean. Are you worried about calls from different threads? If so:
QTimer calls all slots on the thread the timer is started. Therefore if you start the QTimer in the main thread, your slots will only be called in the context of the main thread. There will be no concurrent calls.

This topic is closed to new replies.

Advertisement