Allocating indices on the stack

This commit is contained in:
Vladyslav Baranovskyi
2024-06-14 11:32:20 +03:00
parent a0a4c935e4
commit ca7edc597c

View File

@@ -16,15 +16,18 @@ namespace OpenVulkano::Scene
Geometry* GeometryFactory::MakeCube(float x, float y, float z, const Math::Vector4f& color)
{
Geometry *result = new Geometry();
result->Init(24, 36);
result->SetIndices(new uint32_t[result->indexCount]{
0, 1, 2, 0, 2, 3, // front face index data
4, 5, 6, 4, 6, 7, // back face index data
8, 9, 10, 8, 10, 11, // top face index data
12, 13, 14, 12, 14, 15, // bottom face index data
16, 17, 18, 16, 18, 19, // left face index data
20, 21, 22, 20, 22, 23 // right face index data
}, result->indexCount);
const int indexCount = 36;
result->Init(24, indexCount);
uint32_t indices[indexCount] =
{
0, 1, 2, 0, 2, 3, // front face index data
4, 5, 6, 4, 6, 7, // back face index data
8, 9, 10, 8, 10, 11, // top face index data
12, 13, 14, 12, 14, 15, // bottom face index data
16, 17, 18, 16, 18, 19, // left face index data
20, 21, 22, 20, 22, 23 // right face index data
};
result->SetIndices(indices, result->indexCount);
x *= 0.5f; y *= 0.5f; z *= 0.5f;