Sleep!!

Started by
21 comments, last by michaweyel 17 years, 9 months ago
Quote:Original post by dormlock
I beg to differ on not calling sleep. If your using threads in your engine then your going to need to yeild time in some way. Sleep is the easiest to do. The consequencies of not calling sleep when running multi threaded is that your other threads may not run. I forget to have one of my threads sleep at all and instead it was running a tight loop to dispatch events and it slowed the UI of every program running including the debugger except for iTunes go figure.


You're absolutely correct, when threading I use sleep to make sure all my threads get the time they need. However, I was in my earlier posts assuming that this is a non-threaded app, in which case, I would almost never acutaly call sleep(). If I need to pause a game, I like to know exactly how long it will pause, not at least how long it will pause.
Advertisement
Blueseed,

if I understand your code correctly, your sleep() is called within RestartGame(), which is called by moveBall(), which is called in DrawGLScene(), which is called BEFORE SwapBuffers.

This means that your new frame is presented AFTER the sleep, and this is why you see the Ball at 0.0/0.0 only after the sleep.

You somehow need to call the sleep function after SwapBuffers, or have a call to SwapBuffers in your RestartGame function right BEFORE the sleep call.


Hope that makes sense.
Blueseed,

if I understand your code correctly, your sleep() is called within RestartGame(), which is called by moveBall(), which is called in DrawGLScene(), which is called BEFORE SwapBuffers.

This means that your new frame is presented AFTER the sleep, and this is why you see the Ball at 0.0/0.0 only after the sleep.

You somehow need to call the sleep function after SwapBuffers, or have a call to SwapBuffers in your RestartGame function right BEFORE the sleep call.


Hope that makes sense.

This topic is closed to new replies.

Advertisement