FPS Counter Prob in OpenGL

This is a discussion on FPS Counter Prob in OpenGL within the Game Programming forums, part of the General Programming Boards category; Hey guys. Im just learning OpenGL and i just have a cude spinning with a texture mapped to it. But ...

  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-16-2002 at 12:37 AM.

  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, 01:34 PM
  2. Mouse 'control' prob in OpenGL
    By gazsux in forum Game Programming
    Replies: 5
    Last Post: 04-17-2003, 11: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, 09:18 PM
  5. Displaying FPS in openGL...
    By Jackmar in forum Game Programming
    Replies: 1
    Last Post: 05-22-2002, 08:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21