
#include <WFX/SDL/SDLTimeTask.h>

#include <SDL/SDL.h>

using namespace WFX;
using namespace WFX::kernel;
using namespace WFX::SDL;

bool SDLTimeTask::start() {
    ThisFrame = LastFrame = SDL_GetTicks();
    DeltaTime = 0;
    return true;
}

void SDLTimeTask::stop() {
}

ULong SDLTimeTask::getTicks() {
    return SDL_GetTicks();
}

void SDLTimeTask::update() {
    LastFrame = ThisFrame;
    ThisFrame = SDL_GetTicks();

    DeltaTime = ((Real)(ThisFrame-LastFrame))/1000.0f;
    FPS = 1.0f/DeltaTime;
    
    //if FPS is > DesiredFPS call SDL_Delay
    //TODO: implement

    //call superclass update
    TimeTask::update();

}



