-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics.h
More file actions
80 lines (77 loc) · 2.29 KB
/
Graphics.h
File metadata and controls
80 lines (77 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include "PreWin.h"
#include "MainException.h"
#include <d3d11.h>
#include <wrl.h>
#include <vector>
#include "DxgiInfoManager.h"
#include <d3dcompiler.h>
#include <DirectXMath.h>
#include <memory>
#include <random>
class Graphics
{
friend class Bindable;
public:
class Exception : public MainException {
using MainException::MainException;
public:
static std::string TranslateErrorCode(HRESULT hr) noexcept;
};
class HrException : public Exception {
public:
HrException(int line, const char* file, HRESULT hr, std::vector<std::string> infoMsg = {}) noexcept;
const char* what() const noexcept override;
const char* GetType() const noexcept override;
HRESULT GetErrorCode() 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<std::string> 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) noexcept(!IS_DEBUG);
void SetProjecton(DirectX::FXMMATRIX proj) noexcept;
DirectX::XMMATRIX GetProjection() const noexcept;
void SetCamera(DirectX::FXMMATRIX camOri) noexcept;
DirectX::XMMATRIX GetCamera() const noexcept;
void EnableImgui() noexcept;
void DisableImgui() noexcept;
bool IsImguiEnabled() const noexcept;
private:
bool imguiEnabled = true;
DirectX::XMMATRIX projection;
DirectX::XMMATRIX camera;
#ifndef NDEBUG
DxgiInfoManager infoManager;
#endif
Microsoft::WRL::ComPtr<ID3D11Device> pDevice;
Microsoft::WRL::ComPtr<IDXGISwapChain> pSwap;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> pContext;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> pTarget;
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> pDSV;
};