PDA

View Full Version : FPS using GLUT problem



blood.angel
04-19-2003, 01:03 PM
Im having a problem getting my FPS counter working, it constantly shows 60fps even when drawing a single quad on my 2.4Ghz GF4 computer.

Heres the code:



//calculate the frames per second
frame++;

//get the current time
currenttime = glutGet(GLUT_ELAPSED_TIME);

//check if a second has passed
if (currenttime - timebase > 1000)
{
sprintf(title, "RubixGL v2.0 By Blood Angel FPS: %4.2f", frame*1000.0/(currenttime-timebase));
glutSetWindowTitle(title);
timebase = currenttime;
frame = 0;
}


Its inserted in the main gamestate loop, just after the drawing code but before the call to glutSwapBuffers()
I know this has something to do with the refresh rate of my monitor as I changed it to 80Hz and started to get 80fps.

So how do I get it to show the 200+ true FPS?

shinpaughp
04-19-2003, 01:34 PM
turn off vertical sync through your display/driver properties...

blood.angel
04-19-2003, 01:44 PM
Wow. Thanks. 350fps.

But now the damn thing is superfast. Is there any way to slow it down to the refresh rate level but still have it doing 350fps?

shinpaughp
04-19-2003, 02:15 PM
No.

However, if it is a timing issue, you should implement a time difference function (similar to what you use in the fps calculation) to determine time between frames and use that value to determine motion. I pass the time difference to my fps counter (when it is on) so I am not calling same code.

So, your objects have a velocity based per second and you multiply the time difference (seconds) by the velocity to determine its new position. So, if you have 10 fps or 400 fps the object will move the same distance in same amount of time. Slower machines won't look slow (okay 10 fps does look slow, and jerky but...) and fast machines won't look fast, just fluid.

blood.angel
04-19-2003, 03:17 PM
Thanks again.
On a side note, is that how Quake 3 (and other games) does its timedemos? Just turn off vsycnh?

shinpaughp
04-19-2003, 03:45 PM
I don't know... I haven't seen the demoes you speak of. But, there is a way to toggle vsync through OpenGL at least for Windows... extension wglSwapIntervalEXT. Other platforms may have similar but I don't know what it is. But it also depends on the card, driver, and property settings.