Sha256: 5d9cd1e6be78f348d17f062bc271fae4c16661002d812b3c8867106eb8dc3468

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 Bytes

Contents

#include <Gosu/Timing.hpp>
#include "GraphicsImpl.hpp"

namespace Gosu
{
    namespace
    {
        int current_fps = 0;
    }

    void register_frame()
    {
        static unsigned long current_second = Gosu::milliseconds() / 1000;
        static int frames_in_current_second = 0;

        unsigned long new_sec = Gosu::milliseconds() / 1000;
        if (current_second != new_sec) {
            current_second = new_sec;
            current_fps = frames_in_current_second;
            frames_in_current_second = 0;
        }
        else {
            ++frames_in_current_second;
        }
    }

    int fps()
    {
        return current_fps;
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gosu-2.0.0.pre8 src/FPS.cpp
gosu-2.0.0.pre7 src/FPS.cpp
gosu-2.0.0.pre6 src/FPS.cpp