#ifndef _LI_D3D_H
#define _LI_D3D_H 1

#ifndef _WIN32
#error d3d not availible except on windows
#endif
#include "Renderer.hpp"

#include <imgui.h>
#include <imgui_impl_dx11.h>
#include <d3d11.h>
#include <Windows.h>
#include <string>

namespace Li::Gui {
	class D3D : public Renderer {
	private:
		HWND hwnd;
		ID3D11Device* d3dDevice;
		ID3D11DeviceContext* d3dDeviceContext;
		IDXGISwapChain* swapChain;
		ID3D11RenderTargetView* mainRenderTargetView;
		
		int windowWidth;
		int windowHeight;

		bool createDeviceD3D();
		void createRenderTarget();
		void setupRenderTarget();
		
		void cleanupRenderTarget();
		void cleanupDeviceD3D();
	public:
		ID3D11Device* D3dDevice();
		ID3D11DeviceContext* D3dDeviceContext();

		int CompileShader(std::string shaderSrc, std::string entryPoint, std::string shaderModel, void** shaderObjectOut);
		void Resize(int newWidth, int newHeight);
		void InitImgui();
		void ImGuiNewFrame();
		void Render();
		
		int WindowWidth();
		int WindowHeight();

		D3D(HWND hwnd, int windowWidth, int windowHeight);
		~D3D();
	};
}
#endif