View Full Version : Incorrect timing

05-10-2001, 11:34 AM
I have tried to use timers to sync my OpenGL scenarios. But when I move the program I have build between different platforms I donít get the result I wanted with aspect to frame contra time. Why isnít the timer the same at different platforms?
How should I do my solution?
Do I have to have the timers separate in a thread?

My code looks like this:

timerindex=SetTimer(sc->hWnd,1, 10,NULL);
case WM_TIMER:
return 0;

Can anyone help me?
How do I sync my frames to time?

05-10-2001, 11:42 PM
Normally the Window's timers aren't that accurate, which is why you are having problems. What you is better is to use a high resolution timer to check wheather it is the correct time to do another frame. Try looking at MSDN for:
- Which are the prefered functions for timing but it isn't always avalible
timeGetTime() - which gives time in milliseconds but it is always avalible

You'd then have a window loop something like:

DWORD dwNextFrameTime=0;

while(1) {
while(PeekMessage(NULL,&msg,0,0,PM_REMOVE)) {
if( timeGetTime() > dwNextFrameTime ) {
dwNextFrameTime = timeGetTime() + 30; // which would give ~30fps
// rest of game loop processed here

05-13-2001, 09:58 AM
Thanx, now it works!