Incorrect timing

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?

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

Thanx, now it works!