//
// Created by sfd on 25-4-17.
//

#ifndef WINDOWSWINDOW_H
#define WINDOWSWINDOW_H

#include <Hazel/Renderer/GraphicsContext.h>

#include "Hazel/Core/Window.h"

#include <SDL3/SDL.h>

namespace Hazel
{

    class GraphicsContext;

    class WindowsWindow : public Window
    {
    public:
        WindowsWindow(const WindowProps& props);
        virtual ~WindowsWindow();

        void OnUpdate() override;

        inline unsigned int GetWidth() const override { return m_Data.width; }
        inline unsigned int GetHeight() const override { return m_Data.height; }



        inline void SetEventCallback(const EventCallbackFn& callback) override { m_Data.eventCallback = callback; }
        inline void SetWindowResizeEventCallback(const WindowsResizeCallbackFn& callback) override {OnWindowResize = callback;}
        void        SetVSync(bool enabled) override;
        bool        IsVSync() const override;

        virtual Uint32 GetMainWindowID() const override {return m_windowID; }
        void* GetNativeWindow() const override {return m_Window;}
        void* GetNativeGLContext() const override {return m_Context->GetGLContext();}

    private:
        virtual void Init(const WindowProps& props);
        virtual void Shutdown();

    private:
        SDL_Window*   m_Window;
        Uint32       m_windowID;
		GraphicsContext* m_Context;

        struct WindowData
        {
            std::string     title;
            unsigned int    width;
            unsigned int    height;
            bool            vSync;
            EventCallbackFn eventCallback;
        };

        WindowsResizeCallbackFn OnWindowResize;
        WindowData m_Data;
    };
}

#endif //WINDOWSWINDOW_H
