#pragma once #include "ChiliWin.h" #include "ChiliException.h" #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 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(); // 刷新RGB void ClearBuffer(float red, float green, float blue) noexcept; private: #ifndef NDEBUG DxgiInfoManager infoManager; #endif // 指向Device的指针 ID3D11Device* pDevice = nullptr; // 指向交换链的指针 IDXGISwapChain* pSwap = nullptr; // 指向Context的指针 ID3D11DeviceContext* pContext = nullptr; // 指向View的指针 ID3D11RenderTargetView* pTarget = nullptr; };