Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: FPS using GLUT problem

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    92

    FPS using GLUT problem

    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:
    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?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    601

    Re: FPS using GLUT problem

    turn off vertical sync through your display/driver properties...

  3. #3
    Intern Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    92

    Re: FPS using GLUT problem

    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?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    601

    Re: FPS using GLUT problem

    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.

  5. #5
    Intern Contributor
    Join Date
    Nov 2001
    Location
    Ireland
    Posts
    92

    Re: FPS using GLUT problem

    Thanks again.
    On a side note, is that how Quake 3 (and other games) does its timedemos? Just turn off vsycnh?

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    601

    Re: FPS using GLUT problem

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •