-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShader.h
More file actions
112 lines (92 loc) · 3.36 KB
/
Copy pathShader.h
File metadata and controls
112 lines (92 loc) · 3.36 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// ===========================================================================
/// <summary>
/// Shader.h
/// DirectXIntroduction
/// created by Mehrdad Soleimanimajd on 27.08.2019
/// </summary>
/// <created>ʆϒʅ, 27.08.2019</created>
/// <changed>ʆϒʅ, 04.07.2023</changed>
// ===========================================================================
#ifndef SHADER_H
#define SHADER_H
#include <d3d10_1.h>
#include <d3dcompiler.h> // standard DirectX3D compiler APIs (shader compiler)
#pragma comment (lib, "d3dcompiler.lib") // linkage to the 'd3dcompiler' library
#include <string>
#include "Universe.h"
// shader buffer
class Shader
{
private:
struct Buffer // shader buffer (compiled .cso files holder)
{
byte* buffer;
long long size;
Buffer (void);
~Buffer (void);
void release (void);
};
protected:
ID3D10Device1* device; // pointer to Direct3D device
ID3D10Blob* vertexBuffer; // texture buffer
ID3D10Blob* pixelBuffer; // pixel buffer
ID3D10Blob* errorMsg; // HLSL compilation errors
ID3D10VertexShader* vertexShader; // standard vertex shader
ID3D10PixelShader* pixelShader; // standard pixel shader
ID3D10InputLayout* inputLayout; // standard input layout
ID3D10SamplerState* samplerState; // standard sampler state (textured shaders)
std::wstring entryPoint;
public:
Shader (ID3D10Device1*, std::wstring);
void loadCompiled (std::string&, Buffer*); // read shader data (compiled .cso files)
bool initializeCompiled (std::string*,
D3D10_INPUT_ELEMENT_DESC*, unsigned short); // rendering pipeline (GPU initialization)
bool compile (LPCWSTR*); // compile HLSL using DirectX APIs
bool initialize (D3D10_INPUT_ELEMENT_DESC*, unsigned short,
D3D10_SAMPLER_DESC*); // rendering pipeline (GPU initialization)
ID3D10VertexShader* const getVertexShader (void);
ID3D10PixelShader* const getPixelShader (void);
ID3D10InputLayout* const getInputLayout (void);
ID3D10SamplerState** const getSamplerState (void);
void release (void); // release the shaders resources
};
class ShaderColour : public Shader
{
private:
D3D10_INPUT_ELEMENT_DESC polygonLayoutDesc [2]; // input layout description
unsigned short elementsCount;
std::string files [2];
//unsigned short filesCount;
bool initialized; // true if initialization was successful
public:
ShaderColour (ID3D10Device1*);
const bool& isInitialized (void); // get the initialized state
};
class ShaderTexture : public Shader
{
private:
D3D10_INPUT_ELEMENT_DESC polygonLayoutDesc [2];
unsigned short elementsCount;
D3D10_SAMPLER_DESC samplerDesc; // tecture sampler state description
LPCWSTR files [2];
//unsigned short filesCount;
bool initialized; // true if initialization was successful
public:
ShaderTexture (ID3D10Device1*);
const bool& isInitialized (void); // get the initialized state
};
class ShaderDiffuseLight : public Shader
{
private:
D3D10_INPUT_ELEMENT_DESC polygonLayoutDesc [3];
unsigned int elementsCount;
D3D10_SAMPLER_DESC samplerDesc;
LPCWSTR files [2];
//unsigned short filesCount;
bool initialized; // true if initialization was successful
public:
ShaderDiffuseLight (ID3D10Device1*);
const bool& isInitialized (void); // get the initialized state
};
#endif // !SHADER_H