Recommended Posts

Hello all,
I have been programming for a little while now, and I need to find a way to tell the computer to wait for a little while. I've been using the wait command described at http://www.cplusplus.com/reference/clibrary/ctime/clock.html , but now I need a way to stop the "wait" by pressing a key or something. Basically, is there a way to abort the wait sequence that I have, or is there a better wait sequence? All help is appreciated and thanks in advance. I use C++, OpenGL, and GLUT.

I came up with this quickly, it should work provided you know of a function to get the clock tick in ms. Replace GetCurrentTime() with a mac version that returns number of ms. You should replace the IsKeyboardHit() function with a more appropriate mac version too.

Also, system("pause") may work on a mac however you'll find you'll be waiting forever until someone presses a key.

0

Share this post

Link to post

Share on other sites

Original post by Adam HamiltonYou could use a while loop but I don't know how to get the current tick count on a mac

*** Source Snippet Removed ***

I came up with this quickly, it should work provided you know of a function to get the clock tick in ms. Replace GetCurrentTime() with a mac version that returns number of ms. You should replace the IsKeyboardHit() function with a more appropriate mac version too.

Also, system("pause") may work on a mac however you'll find you'll be waiting forever until someone presses a key.

Thank you so much for this help. I should have thought of it, just a while statement. Oh, and I do know the clock tick thing, it's CLOCKS_PER_SEC (I don't know if that's the same as windows) The only thing that I'm not so sure about is the IsKeyboardHit() function... I use the GLUT glutKeyboardFunc(), which runs "whenever possible", so I'm wondering if I can just tell it that when a key is hit, that it should set a variable (say key_hit) to one, which would be the IsKeyboardHit() replacement... I'll see what I can do with this code. Thanks again. :) You made my debugging day :P