I''ve noticed that by using the common technique for getting an FPS reading in my OpenGL programs, I get vastly different results on different machines. I get around 190 FPS myself, which is reasonable for a scene with only a few texture mapped quads. My friend with a faster processor but a much much slower video card gets about 300, which is believable I guess, since his processor is really fast and it''s such a simple scene. Another friend has a system very close to mine, but runs WinXP. He gets readings of over 1000. Not that it really matters to me how accurate it is, having the overlaid counter is a neat effect anyway.
Windows XP is the best OS to microsoft for OpenGL, this OS have much better performans in OpenGL that others (win98 is too bad for OpenGL). i find a code for frame counter, its working fine.
void CalculateFrameRate() { // Below we create a bunch of static variables because we want to keep the information // in these variables after the function quits. We could make these global but that would // be somewhat messy and superfluous. Note, that normally you don''t want to display this to // the window title bar. This is because it''s slow and doesn''t work in full screen. // Try using the 3D/2D font''s. You can check out the tutorials at www.gametutorials.com.
static float framesPerSecond = 0.0f; // This will store our fps static float lastTime = 0.0f; // This will hold the time from the last frame static char strFrameRate[50] = {0}; // We will store the string here for the window title
// Here we get the current tick count and multiply it by 0.001 to convert it from milliseconds to seconds. // GetTickCount() returns milliseconds (1000 ms = 1 second) so we want something more intuitive to work with. float currentTime = GetTickCount() * 0.001f;
// Increase the frame counter ++framesPerSecond; // char pe[33];
// Now we want to subtract the current time by the last time that was stored. If it is greater than 1 // that means a second has passed and we need to display the new frame rate. Of course, the first time // will always be greater than 1 because lastTime = 0. The first second will NOT be true, but the remaining // ones will. The 1.0 represents 1 second. Let''s say we got 12031 (12.031) from GetTickCount for the currentTime, // and the lastTime had 11230 (11.230). Well, 12.031 - 11.230 = 0.801, which is NOT a full second. So we try again // the next frame. Once the currentTime - lastTime comes out to be greater than a second (> 1), we calculate the // frames for this last second. if( currentTime - lastTime > 1.0f ) { // Here we set the lastTime to the currentTime. This will be used as the starting point for the next second. // This is because GetTickCount() counts up, so we need to create a delta that subtract the current time from. lastTime = currentTime;
// Copy the frames per second into a string to display in the window title bar // sprintf(strFrameRate, "Return Fire Fps: %d", int(framesPerSecond));
char pi[33];
// Set the window title bar to our string SetWindowText(hWnd, strFrameRate);
// Reset the frames per second framesPerSecond = 0; } }
Well, I''ve learn this from the last few forum... You might want to use TimeGetTime() -> from ??? or clock() in time.h in place of GetTickCount() because it is more accurate...
I didn''t look at WinXP the same way as Visualc does, though. My WinXP simply slow things down, compared to Win2000. (Or maybe my PIII 450 is just slow for everything nowadays )