Remove redundancies

This commit is contained in:
Georg Hagen
2025-01-04 03:21:55 +01:00
parent ca93036f31
commit 450f1170b4
7 changed files with 58 additions and 100 deletions

View File

@@ -31,10 +31,9 @@ namespace OpenVulkano
class BillboardExampleAppImpl final : public BillboardExampleApp
{
public:
void Init() override
{
auto engineConfig = OpenVulkano::EngineConfiguration::GetEngineConfiguration();
auto engineConfig = EngineConfiguration::GetEngineConfiguration();
engineConfig->SetPreferFramebufferFormatSRGB(false);
engineConfig->SetFpsCap(0); // monitor's refresh rate
engineConfig->SetVSync(true);
@@ -44,17 +43,17 @@ namespace OpenVulkano
m_cam.Init(70, 16, 9, 0.1f, 100);
m_scene.SetCamera(&m_cam);
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::VERTEX, "Shader/billboardFromSinglePoint");
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::GEOMETRY, "Shader/billboardFromSinglePoint");
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basic");
m_quadBillboardShader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
m_quadBillboardShader.AddShaderProgram(ShaderProgramType::VERTEX, "Shader/billboardFromSinglePoint");
m_quadBillboardShader.AddShaderProgram(ShaderProgramType::GEOMETRY, "Shader/billboardFromSinglePoint");
m_quadBillboardShader.AddShaderProgram(ShaderProgramType::FRAGMENT, "Shader/basic");
m_quadBillboardShader.AddVertexInputDescription(Vertex::GetVertexInputDescription());
m_quadBillboardShader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
m_quadBillboardShader.AddDescriptorSetLayoutBinding(UniformBuffer::DESCRIPTOR_SET_LAYOUT_BINDING, 4);
m_quadBillboardShader.topology = Topology::POINT_LIST;
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::VERTEX, "Shader/billboard");
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basic");
m_shader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
m_shader.AddShaderProgram(ShaderProgramType::VERTEX, "Shader/billboard");
m_shader.AddShaderProgram(ShaderProgramType::FRAGMENT, "Shader/basic");
m_shader.AddVertexInputDescription(Vertex::GetVertexInputDescription());
m_shader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
m_shader.AddDescriptorSetLayoutBinding(UniformBuffer::DESCRIPTOR_SET_LAYOUT_BINDING, 4);
m_shader.cullMode = CullMode::NONE;
@@ -85,13 +84,13 @@ namespace OpenVulkano
geo->vertices[0].color = glm::vec4(1, 1, 1, 1);
else
geo->vertices[0].color = glm::vec4(1, 0, 0, 1);
m_nodesPool[i].SetMatrix(Math::Utils::translate(glm::mat4x4(1.f), Vector3f(-5 + std::rand() % 5, -5 + std::rand() % 5, std::rand() % 5)));
m_nodesPool[i].SetMatrix(translate(glm::mat4x4(1.f), Vector3f(-5 + std::rand() % 5, -5 + std::rand() % 5, std::rand() % 5)));
m_drawablesPool[i].Init(&m_quadBillboardShader, geo, &m_texturedMat, &m_uniBuffer);
}
else
{
*geo = GeometryFactory::MakePyramid(1, 1, glm::vec4(0, 1, 0, 1));
m_nodesPool[i].SetMatrix(Math::Utils::translate(glm::mat4x4(1.f), Vector3f(-5 + std::rand() % 5, -5 + std::rand() % 5, -std::rand() % 10)));
m_nodesPool[i].SetMatrix(translate(glm::mat4x4(1.f), Vector3f(-5 + std::rand() % 5, -5 + std::rand() % 5, -std::rand() % 10)));
m_drawablesPool[i].Init(&m_shader, geo, &m_mat, &m_uniBuffer);
}
m_scene.GetRoot()->AddChild(&m_nodesPool[i]);
@@ -105,8 +104,8 @@ namespace OpenVulkano
m_camController.SetPosition({ 0, 0, 5 });
m_camController.SetBoostFactor(5);
std::shared_ptr<OpenVulkano::Scene::UI::PerformanceInfo> m_perfInfo =
std::make_shared<OpenVulkano::Scene::UI::PerformanceInfo>();
std::shared_ptr<UI::PerformanceInfo> m_perfInfo =
std::make_shared<UI::PerformanceInfo>();
m_ui.AddElement(m_perfInfo);
GetGraphicsAppManager()->GetRenderer()->SetActiveUi(&m_ui);
}
@@ -125,7 +124,7 @@ namespace OpenVulkano
BillboardControlBlock m_bbContolBlock;
PerspectiveCamera m_cam;
UniformBuffer m_uniBuffer;
OpenVulkano::FreeCamCameraController m_camController;
FreeCamCameraController m_camController;
Material m_mat;
Material m_texturedMat;
Shader m_shader;
@@ -133,9 +132,9 @@ namespace OpenVulkano
std::vector<SimpleDrawable> m_drawablesPool;
std::vector<Node> m_nodesPool;
Vector3f_SIMD m_position = { 0, 0, -10 };
OpenVulkano::Scene::UI::SimpleUi m_ui;
UI::SimpleUi m_ui;
std::vector<Geometry> m_geo;
std::shared_ptr<OpenVulkano::Scene::UI::PerformanceInfo> m_perfInfo;
std::shared_ptr<UI::PerformanceInfo> m_perfInfo;
};
IGraphicsApp* BillboardExampleApp::Create() { return new BillboardExampleAppImpl(); }