-
Notifications
You must be signed in to change notification settings - Fork 1
/
Shader.h
53 lines (45 loc) · 1.77 KB
/
Shader.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
#pragma once
#include "DeviceResources.h"
#include "Light.h"
//Class from which we create all shader objects used by the framework
//This single class can be expanded to accomodate shaders of all different types with different parameters
class Shader
{
public:
Shader();
~Shader();
//we could extend this to load in only a vertex shader, only a pixel shader etc. or specialised init for Geometry or domain shader.
//All the methods here simply create new versions corresponding to your needs
bool InitStandard(ID3D11Device * device, WCHAR * vsFilename, WCHAR * psFilename); //Loads the Vert / pixel Shader pair
bool SetShaderParameters(ID3D11DeviceContext * context, DirectX::SimpleMath::Matrix *world, DirectX::SimpleMath::Matrix *view, DirectX::SimpleMath::Matrix *projection, Light *sceneLight1, ID3D11ShaderResourceView* texture1);
void EnableShader(ID3D11DeviceContext * context);
private:
//standard matrix buffer supplied to all shaders
struct MatrixBufferType
{
DirectX::XMMATRIX world;
DirectX::XMMATRIX view;
DirectX::XMMATRIX projection;
};
//buffer for information of a single light
struct LightBufferType
{
DirectX::SimpleMath::Vector4 ambient;
DirectX::SimpleMath::Vector4 diffuse;
DirectX::SimpleMath::Vector3 position;
float padding;
};
//buffer to pass in camera world Position
struct CameraBufferType
{
DirectX::SimpleMath::Vector3 cameraPosition;
float padding;
};
//Shaders
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11Buffer* m_lightBuffer;
};