-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graphics.h
63 lines (61 loc) · 2.09 KB
/
Graphics.h
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
#pragma once
#include <d3d11.h>
#include <wrl.h>
#include "ChiliException.h"
#include "Colors.h"
class Graphics
{
public:
class Exception : public ChiliException
{
public:
Exception( HRESULT hr,const std::wstring& note,const wchar_t* file,unsigned int line );
std::wstring GetErrorName() const;
std::wstring GetErrorDescription() const;
virtual std::wstring GetFullMessage() const override;
virtual std::wstring GetExceptionType() const override;
private:
HRESULT hr;
};
private:
// vertex format for the framebuffer fullscreen textured quad
struct FSQVertex
{
float x,y,z; // position
float u,v; // texcoords
};
public:
Graphics( class HWNDKey& key );
Graphics( const Graphics& ) = delete;
Graphics& operator=( const Graphics& ) = delete;
void EndFrame();
void BeginFrame();
void PutPixel( int x,int y,int r,int g,int b )
{
PutPixel( x,y,{ unsigned char( r ),unsigned char( g ),unsigned char( b ) } );
}
void PutPixel( int x,int y,Color c );
void DrawRect( int x0,int y0,int x1,int y1,Color c );
void DrawRectDim( int x0,int y0,int width,int height,Color c )
{
DrawRect( x0,y0,x0 + width,y0 + height,c );
}
~Graphics();
private:
Microsoft::WRL::ComPtr<IDXGISwapChain> pSwapChain;
Microsoft::WRL::ComPtr<ID3D11Device> pDevice;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> pImmediateContext;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> pRenderTargetView;
Microsoft::WRL::ComPtr<ID3D11Texture2D> pSysBufferTexture;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> pSysBufferTextureView;
Microsoft::WRL::ComPtr<ID3D11PixelShader> pPixelShader;
Microsoft::WRL::ComPtr<ID3D11VertexShader> pVertexShader;
Microsoft::WRL::ComPtr<ID3D11Buffer> pVertexBuffer;
Microsoft::WRL::ComPtr<ID3D11InputLayout> pInputLayout;
Microsoft::WRL::ComPtr<ID3D11SamplerState> pSamplerState;
D3D11_MAPPED_SUBRESOURCE mappedSysBufferTexture;
Color* pSysBuffer = nullptr;
public:
static constexpr int ScreenWidth = 800;
static constexpr int ScreenHeight = 600;
};