#pragma once #include "ChiliWin.h" #include "ChiliException.h" #include #include #include #include "DxgiInfoManager.h" #include #include #include #include #include "ConditionalNoexcept.h" namespace Bind { class Bindable; } class Graphics { friend Bind::Bindable; public: class Exception : public ChiliException { using ChiliException::ChiliException; }; class HrException : public Exception { public: HrException( int line,const char* file,HRESULT hr,std::vector infoMsgs = {} ) noexcept; const char* what() const noexcept override; const char* GetType() const noexcept override; HRESULT GetErrorCode() const noexcept; std::string GetErrorString() const noexcept; std::string GetErrorDescription() const noexcept; std::string GetErrorInfo() const noexcept; private: HRESULT hr; std::string info; }; class InfoException : public Exception { public: InfoException( int line,const char* file,std::vector infoMsgs ) noexcept; const char* what() const noexcept override; const char* GetType() const noexcept override; std::string GetErrorInfo() const noexcept; private: std::string info; }; class DeviceRemovedException : public HrException { using HrException::HrException; public: const char* GetType() const noexcept override; private: std::string reason; }; public: Graphics( HWND hWnd ); Graphics( const Graphics& ) = delete; Graphics& operator=( const Graphics& ) = delete; ~Graphics(); void EndFrame(); void BeginFrame( float red,float green,float blue ) noexcept; void DrawIndexed( UINT count ) noxnd; void SetProjection( DirectX::FXMMATRIX proj ) noexcept; DirectX::XMMATRIX GetProjection() const noexcept; void SetCamera( DirectX::FXMMATRIX cam ) noexcept; DirectX::XMMATRIX GetCamera() const noexcept; void EnableImgui() noexcept; void DisableImgui() noexcept; bool IsImguiEnabled() const noexcept; private: DirectX::XMMATRIX projection; DirectX::XMMATRIX camera; bool imguiEnabled = true; #ifndef NDEBUG DxgiInfoManager infoManager; #endif Microsoft::WRL::ComPtr pDevice; Microsoft::WRL::ComPtr pSwap; Microsoft::WRL::ComPtr pContext; Microsoft::WRL::ComPtr pTarget; Microsoft::WRL::ComPtr pDSV; };