#pragma once

#include "Mesh.h"
#include "Camera.h"

struct SDL_Window;
struct SDL_Surface;

enum class Backendtype {
    DirectX,
    SDL
};

namespace dae
{
	class Renderer final
	{
	public:
		Renderer(SDL_Window* pWindow);
		~Renderer();

		Renderer(const Renderer&) = delete;
		Renderer(Renderer&&) noexcept = delete;
		Renderer& operator=(const Renderer&) = delete;
		Renderer& operator=(Renderer&&) noexcept = delete;

		void Update(const Timer* pTimer);
		void Render() const;

        //Switching Functions
        void NextSamplingState();
        void ToggleNormals();

        void SwitchBackend();

        void ToggleRotation();

        void ToggleUniformClearColor();

    private:
		SDL_Window* m_pWindow{};

		int m_Width{};
		int m_Height{};

		bool m_IsInitialized{ false };

		//DIRECTX
		HRESULT InitializeDirectX();
        void    InitializeSDLRasterizer();

        ID3D11Device* m_DevicePtr{};
        ID3D11DeviceContext* m_DeviceContextPtr{};
        IDXGISwapChain* m_SwapChainPtr{};
        ID3D11Texture2D* m_DepthStencilBufferPtr{};
        ID3D11DepthStencilView* m_DepthStencilViewPtr{};
        ID3D11Resource* m_RenderTargetBufferPtr{};
        ID3D11RenderTargetView* m_RenderTargetViewPtr{};

        SDL_Surface* m_pFrontBuffer{ nullptr };
        SDL_Surface* m_pBackBuffer{ nullptr };
        uint32_t* m_pBackBufferPixels{};


        std::vector<Mesh*> m_meshes{};
        std::vector<std::shared_ptr<Material>> m_materials{};

        Backendtype m_backendType{ Backendtype::DirectX };

        Camera m_Camera{};

        bool m_Rotating{ false };
        float m_currentRotation{};
        bool m_UniformClearColor{ false };

    };
}
