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

Thread: Frame Counter

  1. #1
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    78

    Frame Counter

    I've made a simple frame counter but it's only showing 1FPS and i'm absolutely sure I'va got more than that:-)
    Code:
    .....
    drawing
    .....
    framecount++;
    time+=glutGet(GLUT_ELAPSED_TIME);glutSwapBuffers() ;
    if(time>=1000)
    {
    itoa(framecount,number,10);
    strcpy(fps,number);
    strcat(fps," FPS");
    glutSetWindowTitle(fps);
    framecount=0;
    time=0;
    }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,651

    Re: Frame Counter

    Hi !

    Hmmm, as you set framecount=0 at the end of the drawing code (if elapsed time >= 1000 ? is this ms or what ?)

    Mikael


    [This message has been edited by mikael_aronsson (edited 06-04-2003).]

    [This message has been edited by mikael_aronsson (edited 06-04-2003).]

  3. #3
    Intern Newbie
    Join Date
    Nov 2002
    Posts
    37

    Re: Frame Counter

    GLUT ELAPSED TIME Number of milliseconds since glutInit called (or first call to
    glutGet(GLUT ELAPSED TIME)).

    Time is soon always over 1000.

    So you get 1 fps all the time.

    Hope it helps.

    Claude

  4. #4
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    78

    Re: Frame Counter

    but i do swap buffer more than once per second(1000 miliseconds)and when i do first glutGet(GLUT_ELAPSED_TIME)and next
    glutGet(GLUT_ELAPSED_TIME) should give the difference between these two calls? how should it be done correctly ?

  5. #5
    Intern Newbie
    Join Date
    Nov 2002
    Posts
    37

    Re: Frame Counter

    It says:
    since FIRST call to glutGet.
    So at the 1000th call,you get:
    time of the 1000th call - time of first call .

    This is basically the time since you started
    your program.

    Do you see why it doesn't work?

    Go to http://www.gametutorials.com/
    they have a fps tutorial.

    Bye

    Claude

Posting Permissions

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