   Determining frame rate
  How is frame rate calculated or determined in time-based animation?These are my codes.    BOOL bRetVal;    MSG msg;    Helper::zeroMemory(&msg, sizeof(msg));    LARGE_INTEGER freq, startCounter, endCounter;    FLOAT rate = 0.0f;    FLOAT elapsedCount = 0;    QueryPerformanceFrequency(&freq);    while (msg.message != WM_QUIT)    {   bRetVal = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);   if (bRetVal == -1)   {  DWORD errorCode = GetLastError();  Helper::outputDebugStringLine( TEXT("Error getting window message, %lu (%x).") , errorCode );  return EXIT_FAILURE;   }   else if (bRetVal > 0)   {  if (!TranslateAccelerator(hWnd, hAccel, &msg))  { TranslateMessage(&msg; DispatchMessage(&msg;  }   }   else   {  QueryPerformanceCounter(&startCounter);  DXManager::getInstance().render(rate);  QueryPerformanceCounter(&endCounter);  rate = (endCounter.QuadPart - startCounter.QuadPart - rate) / freq.QuadPart;  elapsedCount += rate;  if (elapsedCount >= 1.0f)  { Helper::outputDebugStringLine(TEXT("FPS = %.2f"), (1.0f / rate)); elapsedCount = 0;  }   }    }I just want to check if I did it correctly. I was just rendering some rotational cube but it's not important, I'm just interested to find out how I can derived FPS like most games do.Assuming the high performance counter is in milliseconds, I had a counter to add up to 1000 and have the fps displayed in the debug output window of my Visual Studio 2005, so it's effectively showing the frame rate every second. Well, it works pretty alright to me, I didn't like get a flood of lines in the debug window, it was quite a reasonable interval at each line displayed.On a slower laptop (Centrino 1.4GHz, crappy class), which I wrote this code on, shows about 60 fps from the above code. However, on the faster machine, P4 3.0GHz NorthBridge (so hot I hate it), it shows roughly about the same as well (Of course the graphics card performance on the desktop is greater than that of the laptop's). I thought on a faster machine/better graphics card, you'd get better frame rates, so I kinda guessed it's probably wrong. I even tried to put up an integer counter to count the number of cycles looped within the message loop, but I get the same result as by just getting the inverse of the differential rate from subtracting the start and end high performance counters.Please show me the light, thanks.   
  Because you have 60 fps on all machines it seems to be that vertical syncronization is on.Turn it off in your graphics driver...hope that helps   ;  Oh yes, you're right. Thank you for pointing that out.I think the frame rate went up considerably high now when I change one of the attributes in D3DPRESENT_PARAMETERS struct, the present interval to D3DPRESENT_INTERVAL_IMMEDIATE.But seriously, is this the right way of doing things? I mean, the whole system start to get a little sluggish, it's like squeezing whatever power I have on my PC just to boost frame rate?   ;Quote:Original post by Zerox MillieniumOh yes, you're right. Thank you for pointing that out.I think the frame rate went up considerably high now when I change one of the attributes in D3DPRESENT_PARAMETERS struct, the present interval to D3DPRESENT_INTERVAL_IMMEDIATE.But seriously, is this the right way of doing things? I mean, the whole system start to get a little sluggish, it's like squeezing whatever power I have on my PC just to boost frame rate?Normally you would want vertical sync to be activated as:1) There really is no point in drawing more frames than the monitor can display.2) When you render out of sync you loose some quality. (tearing artifacts appear as multiple frames are rendered in a single update (Thus you can have one frame in the top part of your monitor, and other frames in the middle and lower parts))You might want to let your users disable it from the options menu though. (If their framerate is below their monitors refreshrate they can get a performance boost by disabling it)   