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 7 of 7

Thread: Fps counter using OpenGL?

  1. #1
    Guest

    Fps counter using OpenGL?

    How do i make a simple Frames per second counter using OpenGL for Visual c++ 6.0???

    an example would be much appreciated.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Fps counter using OpenGL?

    You can't make a frame rate counter with OpenGL, cause OpenGL doesn't provide any timer functions. Use some system timers instead, like timeGetTime or QueryPerformanceCounter. Look in MSDN for more details on how to use them.

    There's a few ways to calculate the FPS, all based on the same formula. FPS = frames / time, where frames is the number of frames rendered, and time is the time taken to render them. For example, measure the time taken to render one or ten (or as many as you like) frames, or count the number of frames rendered in a second.

  3. #3
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    486

    Re: Fps counter using OpenGL?

    Hi,

    Check on my site, I've a little example who use a fps counter.
    http://ibelgique.ifrance.com/Slug-Production/

  4. #4
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    13

    Re: Fps counter using OpenGL?

    go to http://www.gametutorials.com they have good tutorails for opengl and one ids the fps counter check it out

  5. #5
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    13

    Re: Fps counter using OpenGL?

    they are all for VC++

  6. #6
    Guest

    Re: Fps counter using OpenGL?

    Thanks for all your replies

  7. #7
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    17

    Re: Fps counter using OpenGL?

    If you use Glut libraires it's very easy, you have to take the time with the function "glutGet (GLUT_ELAPSED_TIME)" and make a substraction with the previous value:

    time = glutGet(GLUT_ELAPSED_TIME);
    if ((time - base_time) > 1000.0)
    {
    fps=frames*1000.0/(time - base_time);
    base_time = time;
    frames=0;
    }

    The variable "frames" is a counter of frames, and It's to be incremented in each frame (Usually in Draw function).

Posting Permissions

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