TDME2  1.9.200
ShadowMapRenderShader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 #include <vector>
6 
7 #include <tdme/tdme.h>
8 #include <tdme/engine/fwd-tdme.h>
11 #include <tdme/math/Matrix4x4.h>
12 
13 using std::string;
14 using std::unordered_map;
15 using std::vector;
16 
21 
22 /**
23  * Shadow mapping shader to render shadow maps
24  * @author Andreas Drewke
25  */
27 {
28 private:
31  };
32  unordered_map<string, ShadowMapRenderShaderImplementation*> shaders;
33  bool running { false };
35  Engine* engine { nullptr };
36  Renderer* renderer { nullptr };
37  vector<ShadowMapRenderShaderContext> contexts;
38  int32_t lightId { -1 };
39 
40 public:
41  // forbid class copy
43 
44  /**
45  * Public constructor
46  * @param renderer renderer
47  */
49 
50  /**
51  * Destructor
52  */
54 
55  /**
56  * @return if initialized and ready to use
57  */
58  bool isInitialized();
59 
60  /**
61  * Initialize shadow map render shader program
62  */
63  void initialize();
64 
65  /**
66  * Use shadow map render shader program
67  * @param engine engine
68  */
69  void useProgram(Engine* engine);
70 
71  /**
72  * Unuse shadow map render shader program
73  */
74  void unUseProgram();
75 
76  /**
77  * Update matrices
78  * @param contextIdx context index
79  */
80  void updateMatrices(int contextIdx);
81 
82  /**
83  * Update up texture matrix
84  * @param contextIdx context index
85  */
86  void updateTextureMatrix(int contextIdx);
87 
88  /**
89  * Update material
90  * @param contextIdx context index
91  */
92  void updateMaterial(int contextIdx);
93 
94  /**
95  * Update light
96  * @param contextIdx context index
97  * @param lightId light id
98  */
99  void updateLight(int contextIdx, int32_t lightId);
100 
101  /**
102  * Update shader parameters
103  * @param context
104  */
105  void updateShaderParameters(int contextIdx);
106 
107  /**
108  * Bind texture
109  * @param contextIdx context index
110  * @param textureId texture id
111  */
112  void bindTexture(int contextIdx, int32_t textureId);
113 
114  /**
115  * Set up program depth bias mvp matrix
116  * @param contextIdx context index
117  * @param depthBiasMVPMatrix depth bias mvp matrix
118  */
119  void setDepthBiasMVPMatrix(int contextIdx, const Matrix4x4& depthBiasMVPMatrix);
120 
121  /**
122  * Set light id
123  * @param lightId light id to render
124  */
125  void setRenderLightId(int32_t lightId);
126 
127  /**
128  * Set shader
129  * @param id id
130  */
131  void setShader(int contextIdx, const string& id);
132 
133  /**
134  * Load textures
135  * @param pathName path name
136  */
137  void loadTextures(const string& pathName);
138 
139 };
Engine main class.
Definition: Engine.h:131
void initialize()
Initialize shadow map render shader program.
unordered_map< string, ShadowMapRenderShaderImplementation * > shaders
void updateLight(int contextIdx, int32_t lightId)
Update light.
void setDepthBiasMVPMatrix(int contextIdx, const Matrix4x4 &depthBiasMVPMatrix)
Set up program depth bias mvp matrix.
void useProgram(Engine *engine)
Use shadow map render shader program.
void setShader(int contextIdx, const string &id)
Set shader.
void updateTextureMatrix(int contextIdx)
Update up texture matrix.
void updateShaderParameters(int contextIdx)
Update shader parameters.
void bindTexture(int contextIdx, int32_t textureId)
Bind texture.
void unUseProgram()
Unuse shadow map render shader program.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6