#pragma once #include #pragma comment (lib, "d3d11.lib") #include #pragma comment (lib, "d3dcompiler.lib") #include #include #include #include "Logger.h" namespace wrl = Microsoft::WRL; class Graphics { friend class Bindable; public: // 构造函数 Graphics(HWND hWnd, int width, int height); // 单例设计模式,禁止复制 Graphics(const Graphics&) = delete; Graphics& operator=(const Graphics&) = delete; ~Graphics() = default; // 初始化3大件,Device/SwapChain/deviceContext void InitD3D(HWND hWnd, int width, int heigh); void RendorFrame(void); void EndFrame(void); //void DrawTestTriangle(float angle, float x, float y); void DrawIndexed(UINT count) noexcept; void SetProjection(DirectX::FXMMATRIX proj) noexcept; DirectX::XMMATRIX GetProjection() const noexcept; // for camera void SetCamera( Logger& logger, DirectX::XMVECTOR eyePosition, DirectX::XMVECTOR focusPosition, DirectX::XMVECTOR upDirection) noexcept; DirectX::XMMATRIX getLookAtMatrix() noexcept; // for debug wrl::ComPtr getDevice(); wrl::ComPtr getSwapChain(); wrl::ComPtr getContext(); private: int width; int height; DirectX::XMMATRIX projection; // 指向Device的指针 wrl::ComPtr pDevice; // 指向交换链的指针 wrl::ComPtr pSwapChain; // 指向Context的指针 wrl::ComPtr pContext; // 指向View的指针 wrl::ComPtr pTarget; // 指向Depth Buffer View的指针 wrl::ComPtr pDSView; // for camera DirectX::XMVECTOR upDirection; DirectX::XMVECTOR eyePosition; DirectX::XMVECTOR focusPosition; };