Results 1 to 2 of 2

Thread: Calaculating FPS ?

  1. #1
    Peasant wwsoft's Avatar
    Join Date
    Apr 2010
    Location
    Here !
    Posts
    6

    Arrow Calaculating FPS ?

    hello , I am making a game. currently I'm starting to test it on other machines and I need to collect the fps for further development. However I don't know how to do so.

    Can someone show me (provide a few line of code or something) how I could calculate the fps ?

    Thanks,
    wwsoft
    A common mistake that people make when trying to
    design something completely foolproof is to
    underestimate the ingenuity of complete fools.

    -Douglas Adams

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Use the attached "framerate_counter.h"

    Code:
    #include "framerate_counter.h"
    
    void your_program()
    {
       CL_Font font(gc, "tahoma", 24);
       FramerateCounter framerate_counter;
       while(main_loop)
       {
           framerate_counter.frame_shown();
    
           (draw your stuff)
    
          CL_String fps(cl_format("%1 fps", framerate_counter.get_framerate()));
          font.draw_text(gc, 16, gc.get_height()-16, fps, CL_Colorf::white));
          
          window.flip(0);
          CL_KeepAlive::process();
       }
    }
    Attached Files Attached Files

Bookmarks

Bookmarks

Posting Permissions

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