-
Notifications
You must be signed in to change notification settings - Fork 13
/
Sky.h
105 lines (86 loc) · 3.2 KB
/
Sky.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include <memory>
#include "Mesh.h"
#include "SimpleShader.h"
#include "Camera.h"
#include <wrl/client.h> // Used for ComPtr
class Sky
{
public:
// Constructor that loads a DDS cube map file
Sky(
const wchar_t* cubemapDDSFile,
std::shared_ptr<Mesh> mesh,
std::shared_ptr<SimpleVertexShader> skyVS,
std::shared_ptr<SimplePixelShader> skyPS,
Microsoft::WRL::ComPtr<ID3D11SamplerState> samplerOptions,
Microsoft::WRL::ComPtr<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context
);
// Constructor that takes an existing cube map SRV
Sky(
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> cubeMap,
Microsoft::WRL::ComPtr<ID3D11SamplerState> samplerOptions,
Microsoft::WRL::ComPtr<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context
);
// Constructor that loads 6 textures and makes a cube map
Sky(
const wchar_t* right,
const wchar_t* left,
const wchar_t* up,
const wchar_t* down,
const wchar_t* front,
const wchar_t* back,
std::shared_ptr<Mesh> mesh,
std::shared_ptr<SimpleVertexShader> skyVS,
std::shared_ptr<SimplePixelShader> skyPS,
Microsoft::WRL::ComPtr<ID3D11SamplerState> samplerOptions,
Microsoft::WRL::ComPtr<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context
);
// Constructor that takes 6 existing SRVs and makes a cube map
Sky(
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> right,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> left,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> up,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> down,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> front,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> back,
std::shared_ptr<Mesh> mesh,
std::shared_ptr<SimpleVertexShader> skyVS,
std::shared_ptr<SimplePixelShader> skyPS,
Microsoft::WRL::ComPtr<ID3D11SamplerState> samplerOptions,
Microsoft::WRL::ComPtr<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context
);
~Sky();
void Draw(std::shared_ptr<Camera> camera);
private:
void InitRenderStates();
// Helper for creating a cubemap from 6 individual textures
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> CreateCubemap(
const wchar_t* right,
const wchar_t* left,
const wchar_t* up,
const wchar_t* down,
const wchar_t* front,
const wchar_t* back);
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> CreateCubemap(
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> right,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> left,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> up,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> down,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> front,
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> back);
// Skybox related resources
std::shared_ptr<SimpleVertexShader> skyVS;
std::shared_ptr<SimplePixelShader> skyPS;
std::shared_ptr<Mesh> skyMesh;
Microsoft::WRL::ComPtr<ID3D11RasterizerState> skyRasterState;
Microsoft::WRL::ComPtr<ID3D11DepthStencilState> skyDepthState;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> skySRV;
Microsoft::WRL::ComPtr<ID3D11SamplerState> samplerOptions;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context;
Microsoft::WRL::ComPtr<ID3D11Device> device;
};