/******************************************************************************
*	File		-	window.h
*	Author		-	Joey Pollack
*	Date		-	2021/09/01 (y/m/d)
*	Mod Date	-	2021/09/01 (y/m/d)
*	Description	-	Manages the window system using GLFW. This is where GLFW
*                   is initialized. I think this file can completely hide GLFW
*                   but I'm not yet sure...
******************************************************************************/

#ifndef WINDOW_H_
#define WINDOW_H_

#include <glad/gl.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <core/state.h>
#include <utils/opRes.h>

namespace lunarium
{
    class Window
    {
    public:
        Window();

        OpRes Initialize(const State& state);
        bool IsInit() const;

        GLFWwindow* GetWindow();
        bool IsKeyDown(int key) const;
        glm::vec2 GetCursorPos() const;
        void SetCursorPos(glm::vec2 pos);

        void Resize(int width, int height);

        // TODO: See https://www.glfw.org/docs/latest/window_guide.html#window_full_screen
        void ChangeDisplayMode(bool fullscreen, int xPos, int yPos, int width, int height);

        void GetFramebufferSize(int* width, int* height) const;
        void GetPosition(int* x, int* y) const;

        void SetShouldCloseFlag(bool should_close);
        bool ShouldWindowClose() const;
        static void PollEvents();
        void SwapBuffers();

        void Shutdown();

    private:

        // There can only be 1 window for now
        static bool mbIsInit;
        GLFWwindow* mpWindow;

    };
}

#endif  // WINDOW_H_