Thread: FPS Counter Prob in OpenGL

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    4

    FPS Counter Prob in OpenGL

    Hey guys. Im just learning OpenGL and i just have a cude spinning with a texture mapped to it. But i wanted to go off and challenge myself by making an FPS counter. I wanted to have the FPS displayed on the screen but i dont want to have to make my own fonts then use texture mapped quads and such (If anyone knows an easier way to display text on the screen that would be great to).

    Heres what i have so far:

    int end = clock();
    int start = clock();
    ...
    ...
    ...
    ...


    TimeLastFrame = TimeThisFrame;
    TimeThisFrame = (end-start)/CLK_TCK;
    TimeLapsed += TimeThisFrame - TimeLastFrame;
    secondslast = seconds;
    seconds = TimeLapsed / 1000;
    if( seconds != secondslast ) {
    FPS = framecount;


    }
    framecount++;

    ....
    ...
    ....
    ...

    if (keys[VK_F2])
    {
    keys[VK_F2]=FALSE;
    sprintf( Message, "the Frame rate is: %i", FPS );
    MessageBox( NULL, Message, "Current FPS", MB_OK );

    }




    And at the bottom i have it so whenever you prss F2 a message box pops up with the current FPS. But it ALWAYS says 0. So i dont know whats wrong. Any help is greatly appreciated..
    Last edited by brandonp; 07-15-2002 at 11:37 PM.

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    Check the 4th tutorial on this page http://www.gametutorials.com/Tutoria...OpenGL_Pg1.htm

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  2. Mouse 'control' prob in OpenGL
    By gazsux in forum Game Programming
    Replies: 5
    Last Post: 04-17-2003, 10:00 AM
  3. Game update...
    By jdinger in forum Game Programming
    Replies: 14
    Last Post: 11-08-2002, 07:10 AM
  4. SkyLock graphics demo (scrolling, etc.)
    By jdinger in forum Game Programming
    Replies: 9
    Last Post: 06-30-2002, 08:18 PM
  5. Displaying FPS in openGL...
    By Jackmar in forum Game Programming
    Replies: 1
    Last Post: 05-22-2002, 07:40 PM