From b60f404b0e613ffc7c5e4ee43d2d24ff3bb45607 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Mon, 8 Aug 2022 02:15:03 -0400 Subject: [PATCH] Fix cube count & indices logic error in descriptorindexing example --- .../descriptorindexing/descriptorindexing.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/descriptorindexing/descriptorindexing.cpp b/examples/descriptorindexing/descriptorindexing.cpp index 0a10d5e5..b174ac30 100644 --- a/examples/descriptorindexing/descriptorindexing.cpp +++ b/examples/descriptorindexing/descriptorindexing.cpp @@ -126,15 +126,27 @@ public: std::uniform_int_distribution rndDist(0, static_cast(textures.size()) - 1); // Generate cubes with random per-face texture indices - const uint32_t count = 6; + const uint32_t count = 5; for (uint32_t i = 0; i < count; i++) { + // Push indices to buffer + const std::vector cubeIndices = { + 0,1,2,0,2,3, + 4,5,6,4,6,7, + 8,9,10,8,10,11, + 12,13,14,12,14,15, + 16,17,18,16,18,19, + 20,21,22,20,22,23 + }; + for (auto& index : cubeIndices) { + indices.push_back(index + static_cast(vertices.size())); + } // Get random per-Face texture indices that the shader will sample from int32_t textureIndices[6]; for (uint32_t j = 0; j < 6; j++) { textureIndices[j] = rndDist(rndEngine); } // Push vertices to buffer - float pos = 2.5f * i - (count * 2.5f / 2.0f); + float pos = 2.5f * i - (count * 2.5f / 2.0f) + 1.25f; const std::vector cube = { { { -1.0f + pos, -1.0f, 1.0f }, { 0.0f, 0.0f }, textureIndices[0] }, { { 1.0f + pos, -1.0f, 1.0f }, { 1.0f, 0.0f }, textureIndices[0] }, @@ -169,18 +181,6 @@ public: for (auto& vertex : cube) { vertices.push_back(vertex); } - // Push indices to buffer - const std::vector cubeIndices = { - 0,1,2,0,2,3, - 4,5,6,4,6,7, - 8,9,10,8,10,11, - 12,13,14,12,14,15, - 16,17,18,16,18,19, - 20,21,22,20,22,23 - }; - for (auto& index : cubeIndices) { - indices.push_back(index + static_cast(vertices.size())); - } } indexCount = static_cast(indices.size());