aboutsummaryrefslogtreecommitdiff
path: root/source/30-game/CommonVertexIndex.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2023-10-19 22:50:07 -0700
committerrtk0c <[email protected]>2025-08-16 11:31:16 -0700
commit297232d21594b138bb368a42b5b0d085ff9ed6aa (patch)
tree075d5407e1e12a9d35cbee6e4c20ad34e0765c42 /source/30-game/CommonVertexIndex.cpp
parentd5cd34ff69f7fd134d5450696f298af1a864afbc (diff)
The great renaming: switch to "module style"
Diffstat (limited to 'source/30-game/CommonVertexIndex.cpp')
-rw-r--r--source/30-game/CommonVertexIndex.cpp152
1 files changed, 0 insertions, 152 deletions
diff --git a/source/30-game/CommonVertexIndex.cpp b/source/30-game/CommonVertexIndex.cpp
deleted file mode 100644
index e9a3ce6..0000000
--- a/source/30-game/CommonVertexIndex.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-#include "CommonVertexIndex.hpp"
-
-template <typename 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 <typename 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 <typename 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 <typename 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 <typename TVertex>
-static void AssignDepths(TVertex vertices[4], float z) {
- for (int i = 0; i < 4; ++i) {
- auto& vert = vertices[i];
- vert.z = z;
- }
-}
-
-template <typename 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 <typename 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);
-}