Jump to content
  • Advertisement
Sign in to follow this  
giugio

OpenGL gl engine and QT widget

This topic is 3023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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....

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!