#pragma once #include "ChiliWin.h" #include "ChiliException.h" #include #include #include #include "DxgiInfoManager.h" class Graphics { 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() = default; void EndFrame(); // 刷新RGB void ClearBuffer(float red, float green, float blue) noexcept; void DrawTestTriangle(); private: #ifndef NDEBUG DxgiInfoManager infoManager; #endif // 指向Device的指针 Microsoft::WRL::ComPtr pDevice; // 指向交换链的指针 Microsoft::WRL::ComPtr pSwap; // 指向Context的指针 Microsoft::WRL::ComPtr pContext; // 指向View的指针 Microsoft::WRL::ComPtr pTarget; };