FPS: What is it? How to use it?

Hello Guys


I know it doesn't really fit in here but I'd like to ask a few questions about the FPS in Video games:

1) What is the FPS for? What is it's Job?

2) Is the Frame rate equal to the amount, the program Loops trough the main Loop?


I've already checked out Google and Wikipedia and I think I pretty much understood what it is: The amount of Pictures/Images per second...

3) But how can I use that in a simple Framework? I don't get that.

Thanks

1) What is the FPS for? What is it's Job?

FPS = Frames Per Second. It is just how often your graphics card is rendering the screen. The more FPS, the smoother the game will appear. 60FPS at 1080P resolution is the basically the standard to shoot for.

2) Is the Frame rate equal to the amount, the program Loops trough the main Loop?

It's how many times per second your graphics card is producing a rendered screen.

3) But how can I use that in a simple Framework? I don't get that.

I don't understand this question.
1) What is the FPS for? What is it's Job?


FPS or otherwise known as Frames Per Second is basically just used as a way to judge performance in a realtime graphical application. Also as RB said the higher the fps the smoother the game is (Up to certain point of course).

Though to be honest FPS isn't really the best way to measure the performance of a game that you are developing. Instead a better number to look at would be your frame time or how long it takes to process a single frame.

Here is a interested short article on the subject http://www.mvps.org/directx/articles/fps_versus_frame_time.htm

2) Is the Frame rate equal to the amount, the program Loops trough the main Loop?

I've already checked out Google and Wikipedia and I think I pretty much understood what it is: The amount of Pictures/Images per second...


The simple answer is yes, though it can get much more complicated then that.

This can be correct in certain main game loops where every time it loops through it updates the game state, processes user input and renders to the screen. But generally this isn't the case unless it is a simple game.

So sometimes it is kind of the opposite in some main game loops. It isn't the amount of pictures/images per second it is the amount of times you update your games state per second. Since a lot of games have their rendering code update more then they update their game's state. So while they are rendering a lot more in the main game loop they are just rendering the same image over and over.

Usually when you get lag from low FPS it is because the game isn't calling it's update/user input code enough times per second and that effects what is rendered to the screen.

3) But how can I use that in a simple Framework? I don't get that.


What it sounds like you are asking is how to set up a main game loop and how to get your time step correctly.

Here is a simple example of a very simple main game loop that is written with C++ and SFML which is a simple 2D graphics framework.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sf::Time timePerFrame = sf::seconds(1.0f / 60.0f); // 60 frames per second
sf::Clock deltaClock;  
sf::Time timeSinceLastUpdate = sf::Time::Zero;

while (m_Window.isOpen())
{
    sf::Time deltaTime = deltaClock.restart();  
    timeSinceLastUpdate += deltaTime;

    while (timeSinceLastUpdate >= timePerFrame)
    {
        timeSinceLastUpdate -= timePerFrame;

        ProcessInput();
        Update(timePerFrame);  
    }

    Render();
}


This is what a main game loop for a simple game would generally look like. In this main game loop I am running a fixed timestep for the update and user input processing. So the rendering code could be called more then the update/user input code.

A simple main game loop generally just needs to do 3 things.

1) Process the user's input
2) Update the game's state
3) Draw the game's state to the screen.

While more complicated game loops do quite a bit more but I won't go into detail about them here.

Here is a nice little article on main game loops - http://higherorderfun.com/blog/2010/08/17/understanding-the-game-main-loop/

Also if you are looking for more information on timesteps here is a very good article on the subject - http://gafferongames.com/game-physics/fix-your-timestep/

Hopefully this helps answer some of your questions, if you have any others or didn't understand anything I said just let me know and I would be glad to help.
Last edited on
You perfectly helped me out :DDD Thanks a lot

Cheers HalfNOob
Topic archived. No new replies allowed.