-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics.h
More file actions
86 lines (79 loc) · 2.44 KB
/
Graphics.h
File metadata and controls
86 lines (79 loc) · 2.44 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
80
81
82
83
84
85
86
#pragma once
#include "BetterWin.h"
#include "Exceptions.h"
#include <d3d11.h>
#include <wrl.h>
#include <string>
#include <vector>
#include "DXGIInfoManager.h"
#include <d3dcompiler.h>
#include <DirectXMath.h>
#include <memory>
#include <random>
namespace wrl = Microsoft::WRL;
#define SCREEN_W 1280
#define SCREEN_H 960
class Graphics {
friend class Bindable;
private:
#ifndef NDEBUG
DXGIInfoManager infoManager;
#endif // !NDEBUG
wrl::ComPtr<ID3D11Device> pDevice = nullptr;
wrl::ComPtr<IDXGISwapChain> pSwap = nullptr;
wrl::ComPtr<ID3D11DeviceContext> pContext = nullptr;
wrl::ComPtr<ID3D11RenderTargetView> pTarget = nullptr;
wrl::ComPtr<ID3D11DepthStencilView> pDSV = nullptr;
DirectX::XMMATRIX projection;
DirectX::XMMATRIX camera;
bool ImGuiEnabled = true;
public:
Graphics(HWND hWnd);
Graphics(const Graphics&) = delete;
Graphics& operator=(const Graphics&) = delete;
~Graphics() = default;
void endFrame();
void beginFrame(float r, float g, float b) noexcept;
void drawIndexed(unsigned int count) noexcept (!IS_DEBUG);
void setProjection(DirectX::FXMMATRIX p) noexcept;
void enableImGui() noexcept;
void disableImGui() noexcept;
bool isImGuiEnabled() const noexcept;
void setCamera(DirectX::FXMMATRIX c) noexcept;
DirectX::XMMATRIX getCamera() const noexcept;
DirectX::XMMATRIX getProjection() const noexcept;
class Exception : public CorsaException {
using CorsaException::CorsaException;
public:
static std::string translateErrorCode(HRESULT hr) noexcept;
};
class HRESException : public Exception {
public:
HRESException(int line, const char* file, HRESULT hr, std::vector<std::string> infoVec) 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> infoVec) noexcept;
const char* what() const noexcept override;
const char* getType() const noexcept override;
std::string getErrorDescription() const noexcept;
std::string getErrorInfo() const noexcept;
private:
std::string info;
};
class DeviceRemovedException : public HRESException {
using HRESException::HRESException;
public:
const char* getType() const noexcept override;
private:
std::string reason;
};
};