3
3
#include " lepus/gfx/GraphicsEngine/Apis/ApiVk.h"
4
4
5
5
#include " lepus/gfx/GraphicsEngine/Apis/ApiGL/Types/GLShader.h"
6
+ #include " lepus/gfx/GraphicsEngine/Apis/ApiVk/Types/VkMesh.h"
6
7
7
8
#include < lepus/gfx/GraphicsEngine/Apis/ApiGL.h>
8
9
#include < lepus/gfx/GraphicsEngine.h>
@@ -124,6 +125,8 @@ class DemoApp : public system::BaseApp
124
125
options.mainViewport = {width, height};
125
126
options.windowingPtr = windowing;
126
127
128
+ // windowing->SetAsCurrentContext();
129
+
127
130
// Create new graphics engine instance
128
131
gfx::GraphicsEngine engine (&options, windowing);
129
132
@@ -135,26 +138,27 @@ class DemoApp : public system::BaseApp
135
138
136
139
// Load & compile shaders.
137
140
std::string
138
- vertShaderSrc = system ::FileSystem::Read (" ../../Content/GLSL/Unlit/RGBVertex .vert" ),
139
- fragShaderSrc = system ::FileSystem::Read (" ../../Content/GLSL/Unlit/RGBVertex .frag" ),
141
+ vertShaderSrc = system ::FileSystem::Read (" ../../Content/GLSL/Unlit/RGBVertex_GL .vert" ),
142
+ fragShaderSrc = system ::FileSystem::Read (" ../../Content/GLSL/Unlit/RGBVertex_GL .frag" ),
140
143
vertShaderSrc2 = system ::FileSystem::Read (" ../../Content/GLSL/Unlit/SolidColour.vert" ),
141
144
fragShaderSrc2 = system ::FileSystem::Read (" ../../Content/GLSL/Unlit/SolidColour.frag" );
142
145
/* gfx::ShaderCompiledResult
143
146
vertShader = gfx::ShaderCompilerGLSL::Singleton().CompileShader(vertShaderSrc.c_str(), vertShaderSrc.length(), gfx::VertexShader),
144
147
fragShader = gfx::ShaderCompilerGLSL::Singleton().CompileShader(fragShaderSrc.c_str(), fragShaderSrc.length(), gfx::FragmentShader),
145
148
vertShader2 = gfx::ShaderCompilerGLSL::Singleton().CompileShader(vertShaderSrc2.c_str(), vertShaderSrc2.length(), gfx::VertexShader),
146
149
fragShader2 = gfx::ShaderCompilerGLSL::Singleton().CompileShader(fragShaderSrc2.c_str(), fragShaderSrc2.length(), gfx::FragmentShader);
147
- */
150
+
151
+ */
148
152
// Register shader with the API.
149
153
auto & api = engine.GetApi <gfx::GraphicsApiVk>();
150
154
engine.GetSceneGraph ().SetCamera (&m_Camera);
151
155
152
156
lepus::gfx::Material baseMaterial, otherMaterial;
153
- lepus::gfx::GLShader baseShader (lepus::gfx::ShaderInfo (" RGBVertex" )), redShader (lepus::gfx::ShaderInfo (" SolidColour" ));
154
- // baseShader.SetGLProgram(gfx::ShaderCompilerGLSL::Singleton().BuildProgram(vertShader, fragShader));
155
- // redShader.SetGLProgram(gfx::ShaderCompilerGLSL::Singleton().BuildProgram(vertShader2, fragShader2));
157
+ // lepus::gfx::GLShader baseShader(lepus::gfx::ShaderInfo("RGBVertex")), redShader(lepus::gfx::ShaderInfo("SolidColour"));
158
+ /* baseShader.SetGLProgram(gfx::ShaderCompilerGLSL::Singleton().BuildProgram(vertShader, fragShader));
159
+ redShader.SetGLProgram(gfx::ShaderCompilerGLSL::Singleton().BuildProgram(vertShader2, fragShader2));
156
160
baseMaterial.SetShader(&baseShader);
157
- otherMaterial.SetShader (&redShader);
161
+ otherMaterial.SetShader(&redShader);*/
158
162
159
163
types::Vector3 baseColour (1 .f , 1 .f , 1 .f );
160
164
auto baseColourIndex = otherMaterial.Attributes ().Add <const types::Vector3&>(" colour" , baseColour);
@@ -164,11 +168,11 @@ class DemoApp : public system::BaseApp
164
168
m_Camera.Transform ().Origin (m_Camera.Transform ().Forward () * -2 .f );
165
169
166
170
// Instantiate two Renderables in the scene graph, each with its own transform, using the same cube mesh data.
167
- auto cubeMesh = engine.CreateMesh (lepus::utility::Primitives::Cube ());
168
- auto cube = lepus::gfx::Renderable (& cubeMesh, lepus::math::Transform (), baseMaterial);
169
- auto cube2 = lepus::gfx::Renderable (& cubeMesh, lepus::math::Transform (), otherMaterial);
170
- auto cube3 = lepus::gfx::Renderable (& cubeMesh, lepus::math::Transform (), otherMaterial);
171
- auto cube4 = lepus::gfx::Renderable (& cubeMesh, lepus::math::Transform (), baseMaterial);
171
+ auto cubeMesh = static_cast <lepus::gfx::VkMesh*>( engine.CreateMesh (lepus::utility::Primitives::Cube () ));
172
+ auto cube = lepus::gfx::Renderable (cubeMesh, lepus::math::Transform (), baseMaterial);
173
+ auto cube2 = lepus::gfx::Renderable (cubeMesh, lepus::math::Transform (), otherMaterial);
174
+ auto cube3 = lepus::gfx::Renderable (cubeMesh, lepus::math::Transform (), otherMaterial);
175
+ auto cube4 = lepus::gfx::Renderable (cubeMesh, lepus::math::Transform (), baseMaterial);
172
176
173
177
cube.GetTransform ()->Origin (lepus::types::Vector3 (0 .f , 0 .f , -2 .f ));
174
178
cube2.GetTransform ()->Origin (lepus::types::Vector3 (2 .f , 0 .f , 0 .f ));
@@ -221,11 +225,11 @@ class DemoApp : public system::BaseApp
221
225
cube.GetTransform ()->Rotate (lepus::types::Quaternion (lepus::types::Vector3 (0 .f , 1 .f , 0 .f ), PI * -0 .25f ));
222
226
}
223
227
cube.GetTransform ()->Rotate (lepus::types::Quaternion (lepus::types::Vector3 (0 .f , 1 .f , 0 .f ), -deltaTime));
224
- // cube2.GetTransform()->Rotate(lepus::types::Quaternion(lepus::types::Vector3(1.f, 0.f, 0.f), -deltaTime));
228
+ cube2.GetTransform ()->Rotate (lepus::types::Quaternion (lepus::types::Vector3 (1 .f , 0 .f , 0 .f ), -deltaTime));
225
229
cube3.GetTransform ()->Rotate (lepus::types::Quaternion (lepus::types::Vector3 (1 .f , 1 .f , 1 .f ), -deltaTime));
226
230
227
231
// Move the child cube back and forth along the parent's Z-axis
228
- // cube2.GetTransform()->Origin(lepus::types::Vector3(0.f, 0.f, -1.f + ((sinf(runningTime) + 1.f) * 0.5f) * -2.f));
232
+ cube2.GetTransform ()->Origin (lepus::types::Vector3 (0 .f , 0 .f , -1 .f + ((sinf (runningTime) + 1 .f ) * 0 .5f ) * -2 .f ));
229
233
230
234
Tick (deltaTime, keys);
231
235
UpdateUniforms (&api);
0 commit comments