#include "fps_class.h"


fps_class::fps_class()
{
}


fps_class::fps_class(const fps_class& other)
{
}


fps_class::~fps_class()
{
}

void fps_class::Initialize()
{
    m_fps = 0;
    m_count = 0;
    m_minFps = INT_MAX;
    m_maxFps = 0;
    m_frameTime = 0.0f;
    m_previousTime = timeGetTime();
    m_startTime = m_previousTime;

    return;
}

void fps_class::Frame()
{

    unsigned int currentTime = timeGetTime();

    m_frameTime = (currentTime - m_previousTime) * 0.001f;
    m_previousTime = currentTime;
    
    m_count++;

    if (timeGetTime() >= (m_startTime + 1000))
    {
        m_fps = m_count;

        if (m_fps < m_minFps)
            m_minFps = m_fps;

        if (m_fps > m_maxFps)
            m_maxFps = m_fps;
        
        m_count = 0;
        m_startTime = timeGetTime();
    }

    return;
}

int fps_class::GetMinFps() const
{
    return m_minFps;
}

int fps_class::GetMaxFps() const
{
    return m_maxFps;
}

float fps_class::GetFrameTime() const
{
    return m_frameTime;
}

void fps_class::ResetStats()
{
    m_minFps = INT_MAX;
    m_maxFps = 0;
}

int fps_class::GetFps()
{
    return m_fps;
}