TDME2 1.9.121
EngineVKRenderer.cpp
Go to the documentation of this file.
2
3#if defined(_MSC_VER)
4 // this suppresses a warning redefinition of APIENTRY macro
5 #define NOMINMAX
6 #include <windows.h>
7#endif
8#define GLFW_INCLUDE_NONE
9#include <GLFW/glfw3.h>
10
11#include <string>
12
13#include <tdme/tdme.h>
19#include <tdme/engine/Engine.h>
20#include <tdme/engine/Version.h>
23
25
26using std::string;
27
37
38EngineVKRenderer::EngineVKRenderer()
39{
40}
41
43 if (tryIdx > 0 || glfwVulkanSupported() == false) return false;
44 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
45 return true;
46}
47
49 return true;
50}
51
53{
54 if (Engine::lightingShader != nullptr)
56
57 if (Engine::particlesShader != nullptr)
59
60 if (Engine::linesShader != nullptr)
62
63 if (Engine::currentEngine->shadowMapping != nullptr)
65
66 if (Engine::ezrShader != nullptr)
68}
69
71{
72 if (Engine::lightingShader != nullptr)
74
75 if (Engine::particlesShader != nullptr)
77
78 if (Engine::linesShader != nullptr)
80
81 if (Engine::currentEngine->shadowMapping != nullptr)
83
84 if (Engine::ezrShader != nullptr)
86}
87
89{
90 if (Engine::lightingShader != nullptr)
92
93 if (Engine::particlesShader != nullptr)
95
96 if (Engine::linesShader != nullptr)
98
99 if (Engine::currentEngine->shadowMapping != nullptr)
101
102 if (Engine::ezrShader != nullptr)
104}
105
106void EngineVKRenderer::onBindTexture(int contextIdx, int32_t textureId)
107{
108 if (Engine::lightingShader != nullptr)
109 Engine::lightingShader->bindTexture(contextIdx, textureId);
110
111 if (Engine::guiShader != nullptr)
112 Engine::guiShader->bindTexture(textureId);
113
114 if (Engine::currentEngine->shadowMapping != nullptr)
115 Engine::currentEngine->shadowMapping->bindTexture(contextIdx, textureId);
116
117 if (Engine::ezrShader != nullptr)
118 Engine::ezrShader->bindTexture(contextIdx, textureId);
119}
120
122{
123 if (Engine::lightingShader != nullptr)
125
126 if (Engine::currentEngine->shadowMapping != nullptr)
128
129 if (Engine::guiShader != nullptr)
131
132 if (Engine::ezrShader != nullptr)
134}
135
137{
138 if (Engine::lightingShader != nullptr)
140
141 if (Engine::particlesShader != nullptr)
143
144 if (Engine::linesShader != nullptr)
146
147 if (Engine::guiShader != nullptr)
149
150}
151
152void EngineVKRenderer::onUpdateLight(int contextIdx, int32_t lightId)
153{
154 if (Engine::lightingShader != nullptr)
155 Engine::lightingShader->updateLight(contextIdx, lightId);
156
157 if (Engine::currentEngine->shadowMapping != nullptr)
158 Engine::currentEngine->shadowMapping->updateLight(contextIdx, lightId);
159}
160
162{
163 if (Engine::lightingShader != nullptr)
165
166 if (Engine::currentEngine->shadowMapping != nullptr)
168
169 if (Engine::ezrShader != nullptr)
171}
172
174 if (Engine::lightingShader != nullptr)
175 Engine::lightingShader->setShader(contextIdx, getShader(contextIdx));
176
177 if (Engine::currentEngine->shadowMapping != nullptr)
178 Engine::currentEngine->shadowMapping->setShader(contextIdx, getShader(contextIdx));
179
180 if (Engine::ezrShader != nullptr)
181 Engine::ezrShader->setShader(contextIdx, getShader(contextIdx));
182}
183
185 if (Engine::lightingShader != nullptr)
187
188 if (Engine::currentEngine->shadowMapping != nullptr)
190
191 if (Engine::ezrShader != nullptr)
193}
194
195// end point for engine to create renderer
197{
199 Console::println("EngineVKRenderer::createInstance(): Engine and renderer version do not match: '" + EngineVKRenderer::getRendererVersion() + "' != '" + Version::getVersion() + "'");
200 return nullptr;
201 }
202 Console::println("EngineVKRenderer::createInstance(): Creating EngineVKRenderer instance!");
203 return new EngineVKRenderer();
204}
EngineVKRenderer * createInstance()
Engine main class.
Definition: Engine.h:122
static STATIC_DLL_IMPEXT Engine * currentEngine
Definition: Engine.h:180
static STATIC_DLL_IMPEXT EZRShader * ezrShader
Definition: Engine.h:193
static STATIC_DLL_IMPEXT LightingShader * lightingShader
Definition: Engine.h:196
static STATIC_DLL_IMPEXT LinesShader * linesShader
Definition: Engine.h:198
static STATIC_DLL_IMPEXT GUIShader * guiShader
Definition: Engine.h:200
static STATIC_DLL_IMPEXT ParticlesShader * particlesShader
Definition: Engine.h:197
ShadowMapping * shadowMapping
Definition: Engine.h:266
void updateMatrices(int contextIdx)
Update program matrices.
Definition: EZRShader.cpp:79
void setShader(int contextIdx, const string &id)
Set shader.
Definition: EZRShader.cpp:112
void updateTextureMatrix(int contextIdx)
Set up program texture matrix.
Definition: EZRShader.cpp:86
void updateShaderParameters(int contextIdx)
Update shader parameters.
Definition: EZRShader.cpp:106
void updateMaterial(int contextIdx)
Update material.
Definition: EZRShader.cpp:92
void bindTexture(int contextIdx, int32_t textureId)
Bind texture.
Definition: EZRShader.cpp:99
Interface to lighting shader program.
void updateLight(int contextIdx, int32_t lightId)
Update light to program.
void updateMatrices(int contextIdx)
Update matrices to program.
void updateEffect(int contextIdx)
Update effect to program.
void setShader(int contextIdx, const string &id)
Set shader.
void updateTextureMatrix(int contextIdx)
Update texture matrix to program.
void updateShaderParameters(int contextIdx)
Update shader parameters.
void updateMaterial(int contextIdx)
Update material to program.
void bindTexture(int contextIdx, int32_t textureId)
Bind texture.
void updateMatrices(int contextIdx)
Update matrices to program.
void updateEffect(int contextIdx)
Update effect to program.
Definition: LinesShader.cpp:85
void updateMatrices(int contextIdx)
Update matrices to program.
void updateEffect(int contextIdx)
Update effect to program.
Engine connector of VK renderer to other engine functionality.
void onUpdateCameraMatrix(int contextIdx) override
Update camera matrix event.
void onUpdateModelViewMatrix(int contextIdx) override
Update model view matrix event.
void onUpdateProjectionMatrix(int contextIdx) override
Update projection matrix event.
void onUpdateTextureMatrix(int contextIdx) override
Update texture matrix for active texture unit event.
void onBindTexture(int contextIdx, int32_t textureId) override
On bind texture event.
void onUpdateMaterial(int contextIdx) override
On update material.
bool prepareWindowSystemRendererContext(int tryIdx) override
Prepare window system renderer context.
void onUpdateEffect(int contextIdx) override
Update material.
bool initializeWindowSystemRendererContext(GLFWwindow *glfwWindow) override
Initialize window system renderer context.
void onUpdateLight(int contextIdx, int32_t lightId) override
Update light.
void onUpdateShaderParameters(int contextIdx) override
On update shader parameters.
void onUpdateShader(int contextIdx) override
On update shader.
const string & getShader(int contextIdx)
Get shader.
Definition: Renderer.h:1167
void updateLight(int contextIdx, int32_t lightId)
Update light.
void updateMatrices(int contextIdx)
Update matrices.
void setShader(int contextIdx, const string &id)
Set shader.
void updateTextureMatrix(int contextIdx)
Update texture matrix.
void updateShaderParameters(int contextIdx)
Update shader parameters.
void updateMaterial(int contextIdx)
Update material.
void bindTexture(int contextIdx, int32_t textureId)
Bind texture.
void updateEffect()
Update effect to program.
Definition: GUIShader.cpp:139
void bindTexture(int32_t textureId)
Bind texture.
Definition: GUIShader.cpp:125
void updateTextureMatrix()
Update texure matrix to program.
Definition: GUIShader.cpp:152
Console class.
Definition: Console.h:26
static string getVersion()
Definition: Version.cpp:11