diff options
Diffstat (limited to 'source/Game/CommonVertexIndex.cpp')
-rw-r--r-- | source/Game/CommonVertexIndex.cpp | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/source/Game/CommonVertexIndex.cpp b/source/Game/CommonVertexIndex.cpp deleted file mode 100644 index 786274e..0000000 --- a/source/Game/CommonVertexIndex.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "CommonVertexIndex.hpp" - -template <class TNumber> -static void AssignIndices(TNumber indices[6], TNumber startIdx) { - // Triangle #1 - indices[0] = startIdx + 1; // Top right - indices[1] = startIdx + 0; // Top left - indices[2] = startIdx + 3; // Bottom left - // Triangle #2 - indices[3] = startIdx + 1; // Top right - indices[4] = startIdx + 3; // Bottom left - indices[5] = startIdx + 2; // Bottom right -} - -template <class TNumber> -static void AssignIndices(TNumber indices[6], TNumber topLeft, TNumber topRight, TNumber bottomRight, TNumber bottomLeft) { - // Triangle #1 - indices[0] = topRight; - indices[1] = topLeft; - indices[2] = bottomLeft; - // Triangle #2 - indices[3] = topRight; - indices[4] = bottomLeft; - indices[5] = bottomRight; -} - -template <class TVertex> -static void AssignPositions(TVertex vertices[4], const Rect<float>& rect) { - // Top left - vertices[0].x = rect.x0(); - vertices[0].y = rect.y0(); - // Top right - vertices[1].x = rect.x1(); - vertices[1].y = rect.y0(); - // Bottom right - vertices[2].x = rect.x1(); - vertices[2].y = rect.y1(); - // Bottom left - vertices[3].x = rect.x0(); - vertices[3].y = rect.y1(); -} - -template <class TVertex> -static void AssignPositions(TVertex vertices[4], glm::vec2 bl, glm::vec2 tr) { - // Top left - vertices[0].x = bl.x; - vertices[0].y = tr.y; - // Top right - vertices[1].x = tr.x; - vertices[1].y = tr.y; - // Bottom right - vertices[2].x = tr.x; - vertices[2].y = bl.y; - // Bottom left - vertices[3].x = bl.x; - vertices[3].y = bl.y; -} - -template <class TVertex> -static void AssignDepths(TVertex vertices[4], float z) { - for (int i = 0; i < 4; ++i) { - auto& vert = vertices[i]; - vert.z = z; - } -} - -template <class TVertex> -static void AssignTexCoords(TVertex vertices[4], const Subregion& texcoords) { - // Top left - vertices[0].u = texcoords.u0; - vertices[0].v = texcoords.v1; - // Top right - vertices[1].u = texcoords.u1; - vertices[1].v = texcoords.v1; - // Bottom right - vertices[2].u = texcoords.u1; - vertices[2].v = texcoords.v0; - // Bottom left - vertices[3].u = texcoords.u0; - vertices[3].v = texcoords.v0; -} - -template <class TVertex> -static void AssignColors(TVertex vertices[4], RgbaColor color) { - for (int i = 0; i < 4; ++i) { - auto& vert = vertices[i]; - vert.r = color.r; - vert.g = color.g; - vert.b = color.b; - vert.a = color.a; - } -} - -void Index_U16::Assign(uint16_t indices[6], uint16_t startIdx) { - ::AssignIndices(indices, startIdx); -} - -void Index_U16::Assign(uint16_t indices[6], uint16_t startIdx, uint16_t topLeft, uint16_t topRight, uint16_t bottomRight, uint16_t bottomLeft) { - ::AssignIndices<uint16_t>(indices, startIdx + topLeft, startIdx + topRight, startIdx + bottomRight, startIdx + bottomLeft); -} - -void Index_U16::Assign(uint16_t indices[6], uint16_t topLeft, uint16_t topRight, uint16_t bottomRight, uint16_t bottomLeft) { - ::AssignIndices<uint16_t>(indices, topLeft, topRight, bottomRight, bottomLeft); -} - -void Index_U32::Assign(uint32_t indices[6], uint32_t startIdx) { - ::AssignIndices(indices, startIdx); -} - -void Index_U32::Assign(uint32_t indices[6], uint32_t startIdx, uint32_t topLeft, uint32_t topRight, uint32_t bottomRight, uint32_t bottomLeft) { - ::AssignIndices<uint32_t>(indices, startIdx + topLeft, startIdx + topRight, startIdx + bottomRight, startIdx + bottomLeft); -} - -void Index_U32::Assign(uint32_t indices[6], uint32_t topLeft, uint32_t topRight, uint32_t bottomRight, uint32_t bottomLeft) { - ::AssignIndices<uint32_t>(indices, topLeft, topRight, bottomRight, bottomLeft); -} - -void Vertex_PC::Assign(Vertex_PC vertices[4], const Rect<float>& rect) { - ::AssignPositions(vertices, rect); -} - -void Vertex_PC::Assign(Vertex_PC vertices[4], glm::vec2 bottomLeft, glm::vec2 topRight) { - ::AssignPositions(vertices, bottomLeft, topRight); -} - -void Vertex_PC::Assign(Vertex_PC vertices[4], float z) { - ::AssignDepths(vertices, z); -} - -void Vertex_PC::Assign(Vertex_PC vertices[4], RgbaColor color) { - ::AssignColors(vertices, color); -} - -void Vertex_PTC::Assign(Vertex_PTC vertices[4], const Rect<float>& rect) { - ::AssignPositions(vertices, rect); -} - -void Vertex_PTC::Assign(Vertex_PTC vertices[4], glm::vec2 bottomLeft, glm::vec2 topRight) { - ::AssignPositions(vertices, bottomLeft, topRight); -} - -void Vertex_PTC::Assign(Vertex_PTC vertices[4], float z) { - ::AssignDepths(vertices, z); -} - -void Vertex_PTC::Assign(Vertex_PTC vertices[4], const Subregion& texcoords) { - ::AssignTexCoords(vertices, texcoords); -} - -void Vertex_PTC::Assign(Vertex_PTC vertices[4], RgbaColor color) { - ::AssignColors(vertices, color); -} |