#ifndef BSK_ENGINE_H
#define BSK_ENGINE_H

#include <basilisk/util/includes.h>
#include <basilisk/IO/window.h>
#include <basilisk/IO/keyboard.h>
#include <basilisk/IO/mouse.h>
#include <basilisk/resource/resourceServer.h>
#include <basilisk/render/frame.h>
#include <basilisk/util/splashScreen.h>

namespace bsk::internal {

class Engine {
    private:
        Window* window;
        Keyboard* keyboard;
        Mouse* mouse;

        Frame* frame;
        static std::unique_ptr<ResourceServer> resourceServer;
        bool autoMouseGrab;

    public:
        Engine(int width=800, int height=800, const char* title="Basilisk", bool autoMouseGrab=true, bool showSplash=false);
        ~Engine();

        bool isRunning() { return window->isRunning(); }
        void update();
        void render();
        void useContext();
        void setResolution(unsigned int width, unsigned int height);
        
        inline Window* getWindow() const { return window; }
        inline Mouse* getMouse() const { return mouse; }
        inline Keyboard* getKeyboard() const { return keyboard; }
        inline Frame* getFrame() const { return frame; }
        inline double getDeltaTime() { return window->getDeltaTime(); }
        static ResourceServer* getResourceServer() { return resourceServer.get(); }

        inline void enableDepthTest() { window->enableDepthTest(); }
        inline void enableCullFace() { window->enableCullFace(); }
        inline void enableMultisample() { window->enableMultisample(); }
        inline void enableBlend() { window->enableBlend(); }
        inline void enableVSync() { window->enableVSync(); }
        inline void disableDepthTest() { window->disableDepthTest(); }
        inline void disableCullFace() { window->disableCullFace(); }
        inline void disableMultisample() { window->disableMultisample(); }
        inline void disableBlend() { window->disableBlend(); }
        inline void disableVSync() { window->disableVSync(); }
        void showSplash();
};

}

#endif