rework examples according to new changes
This commit is contained in:
@@ -73,12 +73,12 @@ namespace OpenVulkano
|
||||
m_uniBuffer.setId = 3;
|
||||
m_drawablesPool.resize(cntDrawables);
|
||||
m_nodesPool.resize(cntDrawables);
|
||||
m_geo.reserve(cntDrawables);
|
||||
m_geo.resize(cntDrawables);
|
||||
m_texturedMat.texture = &Texture::PLACEHOLDER;
|
||||
|
||||
for (uint32_t i = 0; i < cntDrawables; i++)
|
||||
{
|
||||
Geometry* geo = nullptr;
|
||||
Geometry* geo = &m_geo[i];
|
||||
m_nodesPool[i].Init();
|
||||
if (i < quadsCnt)
|
||||
{
|
||||
@@ -94,11 +94,10 @@ namespace OpenVulkano
|
||||
}
|
||||
else
|
||||
{
|
||||
geo = GeometryFactory::MakePyramid(1, 1, glm::vec4(0, 1, 0, 1));
|
||||
*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_drawablesPool[i].Init(&m_shader, geo, &m_mat, &m_uniBuffer);
|
||||
}
|
||||
m_geo.push_back(geo);
|
||||
m_scene.GetRoot()->AddChild(&m_nodesPool[i]);
|
||||
m_nodesPool[i].AddDrawable(&m_drawablesPool[i]);
|
||||
}
|
||||
@@ -123,10 +122,6 @@ namespace OpenVulkano
|
||||
|
||||
void Close() override
|
||||
{
|
||||
for (Geometry* g: m_geo)
|
||||
{
|
||||
delete g;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -143,7 +138,7 @@ namespace OpenVulkano
|
||||
std::vector<Node> m_nodesPool;
|
||||
Vector3f_SIMD m_position = { 0, 0, -10 };
|
||||
OpenVulkano::Scene::UI::SimpleUi m_ui;
|
||||
std::vector<Geometry*> m_geo;
|
||||
std::vector<Geometry> m_geo;
|
||||
std::shared_ptr<OpenVulkano::Scene::UI::PerformanceInfo> m_perfInfo;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace OpenVulkano
|
||||
std::vector<SimpleDrawable> drawablesPool;
|
||||
std::vector<Node> nodesPool;
|
||||
Vector3f_SIMD position = {0, 0, -10};
|
||||
std::vector<Geometry> m_geos;
|
||||
|
||||
OpenVulkano::Scene::UI::SimpleUi m_ui;
|
||||
std::shared_ptr<OpenVulkano::Scene::UI::PerformanceInfo> m_perfInfo;
|
||||
@@ -61,11 +62,14 @@ namespace OpenVulkano
|
||||
shader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basic");
|
||||
shader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
|
||||
drawablesPool.resize(GEOS);
|
||||
m_geos.reserve(GEOS);
|
||||
for (uint32_t i = 0; i < GEOS; i++)
|
||||
{
|
||||
Geometry* geo = GeometryFactory::MakeCube(std::rand() % 1000 / 1000.0f + 0.01f, std::rand() % 1000 / 1000.0f + 0.01f, std::rand() % 1000 / 1000.0f + 0.01f,
|
||||
Vector4f((std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, 1));
|
||||
drawablesPool[i].Init(&shader, geo, &mat);
|
||||
m_geos.push_back(GeometryFactory::MakeCube(
|
||||
std::rand() % 1000 / 1000.0f + 0.01f, std::rand() % 1000 / 1000.0f + 0.01f,
|
||||
std::rand() % 1000 / 1000.0f + 0.01f,
|
||||
Vector4f((std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, 1)));
|
||||
drawablesPool[i].Init(&shader, &m_geos[i], &mat);
|
||||
}
|
||||
nodesPool.resize(OBJECTS);
|
||||
for (uint32_t i = 0; i < OBJECTS; i++)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenVulkano
|
||||
{
|
||||
struct SceneElement
|
||||
{
|
||||
Scene::Geometry *m_geometry;
|
||||
Scene::Geometry m_geometry;
|
||||
Scene::SimpleDrawable m_drawable;
|
||||
Scene::Node m_node;
|
||||
};
|
||||
@@ -70,7 +70,7 @@ namespace OpenVulkano
|
||||
|
||||
void CompleteSceneElement(SceneElement *dest)
|
||||
{
|
||||
dest->m_drawable.Init(&m_shader, dest->m_geometry, &m_material);
|
||||
dest->m_drawable.Init(&m_shader, &dest->m_geometry, &m_material);
|
||||
dest->m_node.Init();
|
||||
m_scene.GetRoot()->AddChild(&dest->m_node);
|
||||
dest->m_node.SetUpdateFrequency(Scene::UpdateFrequency::Always);
|
||||
|
||||
@@ -49,9 +49,9 @@ namespace OpenVulkano
|
||||
shader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basicTexture");
|
||||
shader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
|
||||
shader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
|
||||
Geometry* geo = GeometryFactory::MakeCube();
|
||||
static Geometry geo = GeometryFactory::MakeCube();
|
||||
mat.texture = &Texture::PLACEHOLDER;
|
||||
drawable.Init(&shader, geo, &mat);
|
||||
drawable.Init(&shader, &geo, &mat);
|
||||
node.Init();
|
||||
scene.GetRoot()->AddChild(&node);
|
||||
node.SetUpdateFrequency(UpdateFrequency::Always);
|
||||
|
||||
Reference in New Issue
Block a user