Hey all,
Here's another "What's the current best practice" question from me:
What's the best way to time a game loop? I'm looking for a call like Windows' timeGetTime: reasonably cheap (timeGetTime returns a DWORD, no fancy floats or int64s) and times accurately to the millisecond. Better resolution is also fine, but I don't really want to go lower than milliseconds (so time() is out of the question with its one-second resolution).
I'm looking for something similar on Linux, something that's also supported on the GP2X obviously, and something that's not too heavy-handed. There's gotta be a cheap tick-timer somewhere... I just don't know what it's called.
And in case you're wondering, sleeping won't cut it. I want to time my loop independently of how long a cycle takes, and skip frames if drawing is too slow. Plus, if you calculate your sleep for a certain framerate, your framerate will actually be lower because a cycle does not actually take (sleeptime) but (looptime + sleeptime).
So what are you using?
Here's another "What's the current best practice" question from me:
What's the best way to time a game loop? I'm looking for a call like Windows' timeGetTime: reasonably cheap (timeGetTime returns a DWORD, no fancy floats or int64s) and times accurately to the millisecond. Better resolution is also fine, but I don't really want to go lower than milliseconds (so time() is out of the question with its one-second resolution).
I'm looking for something similar on Linux, something that's also supported on the GP2X obviously, and something that's not too heavy-handed. There's gotta be a cheap tick-timer somewhere... I just don't know what it's called.
And in case you're wondering, sleeping won't cut it. I want to time my loop independently of how long a cycle takes, and skip frames if drawing is too slow. Plus, if you calculate your sleep for a certain framerate, your framerate will actually be lower because a cycle does not actually take (sleeptime) but (looptime + sleeptime).
So what are you using?