Results 1 to 4 of 4

Thread: Displaying frames per second

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2014
    Posts
    10

    Displaying frames per second

    Is there a piece of code that will create a window and display how many frames per second my animation is running at? Any help is appreciated!

  2. #2
    Member Contributor
    Join Date
    Jul 2014
    Location
    Italy, Lissone
    Posts
    80
    Quote Originally Posted by ChucklesDarling View Post
    Is there a piece of code that will create a window and display how many frames per second my animation is running at? Any help is appreciated!
    hi, to display frame per second you have to do like this (it's pseudocode):
    Code :
    framerate function()
    {
    framecount + 1;
     
    getCurrentTime;
    if(delta_time > 1000) // delta_time = current_time - time_base
    {
    print(frame * 1000 / delta_time);
     
    time_base = current_time();
     
    framecount = 0;
     
     
    }
    }

    so what you have to increase your frame count then get the current time check if the delta time is > 1000 print the framerate (wich corrispond to frame * 1000 / delta time) then swap the time and reset the framecount, it works for me, it should work for you

    about the window all depends to what library are you using (or you want to use) and there are tens of tutorials for every library you may use...

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2014
    Posts
    10
    Ohh right okay. I'll give it ago. I think I'm kind of okay with the window now, its just the fps display I was stuck on. Thanks for your help!

  4. #4
    Member Newbie
    Join Date
    Apr 2014
    Posts
    47
    When using FPS, the rate for the last second isn't necessarily the best rate. I like also to use an average over the life of the program, minimum FPS (after the program is running), and an average FPS over the last few seconds or so. This helped me pin down a specific conditions where rendering or game logic really slowed frame rate down and gave me a better idea of what FPS my programs were running at in different conditions (game levels, or with different number of enemies/game objects).

    Be sure to also use a time and memory profiler (e.g. valgrind on linux) to check for other performance issues. Xcode has tools which can show if you are CPU or GPU bound, which helps a lot. Also look into gDEBugger.

Similar Threads

  1. Displaying sequence of frames in loop on projector
    By samvdj in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-17-2013, 05:51 AM
  2. problem in displaying the frames
    By Giacomo in forum OpenGL ES
    Replies: 0
    Last Post: 08-10-2005, 04:46 AM
  3. help with frames per second
    By mdog1234 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-06-2002, 02:28 PM
  4. Frames Per Second
    By smiley in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-28-2002, 07:05 AM
  5. frames ???
    By Blza in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-26-2000, 07:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean