diff options
author | rtk0c <[email protected]> | 2022-06-03 23:30:01 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-06-03 23:30:01 -0700 |
commit | 791b3f354b378769bffe623b05f1305c91b77101 (patch) | |
tree | 5409b311e6232eb4a6d3f8259b780d76b8ee1c59 /ProjectBrussel/Game/CommonVertexIndex.hpp | |
parent | 60ccc62f4934e44ad5b905fdbcf458302b8d8a09 (diff) |
Changeset: 64 [WIP] Rename directoriesmaster-switch-to-build2
Diffstat (limited to 'ProjectBrussel/Game/CommonVertexIndex.hpp')
-rw-r--r-- | ProjectBrussel/Game/CommonVertexIndex.hpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/ProjectBrussel/Game/CommonVertexIndex.hpp b/ProjectBrussel/Game/CommonVertexIndex.hpp new file mode 100644 index 0000000..adb81b6 --- /dev/null +++ b/ProjectBrussel/Game/CommonVertexIndex.hpp @@ -0,0 +1,76 @@ +#pragma once + +#include "Color.hpp" +#include "RcPtr.hpp" +#include "Rect.hpp" +#include "Texture.hpp" +#include "VertexIndex.hpp" + +#include <cstdint> + +// Initialized in main() +inline RcPtr<VertexFormat> gVformatStandard{}; +inline RcPtr<VertexFormat> gVformatStandardSplit{}; + +// Suffixes: +// - _P_osition +// - _T_exture coordiantes +// - _C_olor +// - _N_ormal +// When an number is attached to some suffix, it means there are N number of this element + +struct Index_U16 { + uint16_t value; + + static void Assign(uint16_t indices[6], uint16_t startIdx); + static void Assign(uint16_t indices[6], uint16_t startIdx, uint16_t topLeft, uint16_t topRight, uint16_t bottomRight, uint16_t bottomLeft); + static void Assign(uint16_t indices[6], uint16_t topLeft, uint16_t topRight, uint16_t bottomRight, uint16_t bottomLeft); +}; + +struct Index_U32 { + uint32_t value; + + static void Assign(uint32_t indices[6], uint32_t startIdx); + static void Assign(uint32_t indices[6], uint32_t startIdx, uint32_t topLeft, uint32_t topRight, uint32_t bottomRight, uint32_t bottomLeft); + static void Assign(uint32_t indices[6], uint32_t topLeft, uint32_t topRight, uint32_t bottomRight, uint32_t bottomLeft); +}; + +struct Vertex_PC { + float x, y, z; + uint8_t r, g, b, a; + + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PC vertices[4], const Rect<float>& rect); + /// Assign position in regular cartesian coordinate space (x increases from left to right, y increases from top to bottom). + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PC vertices[4], glm::vec2 bottomLeft, glm::vec2 topRight); + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PC vertices[4], float z); + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PC vertices[4], RgbaColor color); +}; + +struct Vertex_PTC { + float x, y, z; + float u, v; + uint8_t r, g, b, a; + + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PTC vertices[4], const Rect<float>& rect); + /// Assign position in regular cartesian coordinate space (x increases from left to right, y increases from top to bottom). + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PTC vertices[4], glm::vec2 bottomLeft, glm::vec2 topRight); + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PTC vertices[4], float z); + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PTC vertices[4], const Subregion& uvs); + /// Assumes the 4 vertices come in TL, TR, BR, BL order. + static void Assign(Vertex_PTC vertices[4], RgbaColor color); +}; + +struct Vertex_PTNC { + float x, y, z; + float nx, ny, nz; + float u, v; + uint8_t r, g, b, a; +}; |