// GLFW Engine.
// -----------------------------------------------------------------------------
// Copyright (C) 2011, ZEUS project (See authors)
//
// This program is open source and distributed under the New BSD License. See
// license for more detail.
// -----------------------------------------------------------------------------

#include <Core/GLFWEngine.h>
#include <Devices/GLFWKeyboard.h>
#include <Devices/GLFWMouse.h>
#include <Display/Camera.h>
#include <Display/GLFWWindow.h>
#include <Math/Vector.h>

#include <GL/glfw.h>

#include <stdlib.h>

using namespace ZEUS::Display;
using namespace ZEUS::Devices;
using namespace ZEUS::Math;

namespace ZEUS {
    namespace Core {

        GLFWEngine::GLFWEngine()
            : IEngine() {
            if (!glfwInit()) exit(EXIT_FAILURE);

            Vector<2, unsigned int> res(800, 600);
            window = new Display::GLFWWindow(res);

            IKeyboard::Add<GLFWKeyboard>();
            IMouse::Add<GLFWMouse>();
        }
        
        GLFWEngine::~GLFWEngine(){
            glfwTerminate();
        }
        
        GLFWEngine* GLFWEngine::CreateEngine(){
            GLFWEngine* tmp = new GLFWEngine();
            engine = tmp;
            return tmp;
        }
        
        void GLFWEngine::Initialize(){
            glfwSetTime(0.0);
        }

        double GLFWEngine::GetImplTime(){
            return glfwGetTime();
        }

    }
}
