diff options
author | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-04-17 20:08:57 -0700 |
commit | 5424a1d5434e3ddd911a504719918c2df027e2fd (patch) | |
tree | 6275aab13140d81dcc46c8290e73ac9a8bbb5605 /source/GraphicsTags.cpp | |
parent | afcac59c7d04f4337d6b04ebed8cac7e871ccc50 (diff) |
Changeset: 8 Initial work on sprites and texture system
Diffstat (limited to 'source/GraphicsTags.cpp')
-rw-r--r-- | source/GraphicsTags.cpp | 105 |
1 files changed, 99 insertions, 6 deletions
diff --git a/source/GraphicsTags.cpp b/source/GraphicsTags.cpp index d2da091..b389acf 100644 --- a/source/GraphicsTags.cpp +++ b/source/GraphicsTags.cpp @@ -1,6 +1,6 @@ #include "GraphicsTags.hpp" -#include <absl/container/flat_hash_map.h> +#include <robin_hood.h> #include <cstddef> #include <cstdint> @@ -14,7 +14,10 @@ std::string_view Tags::NameOf(VertexElementSemantic semantic) { case VES_Normal: return "Normal"sv; case VES_Color1: return "Color1"sv; case VES_Color2: return "Color2"sv; - case VES_Texture_coordinates: return "Texture_coordinates"sv; + case VES_Color3: return "Color3"sv; + case VES_TexCoords1: return "TexCoords1"sv; + case VES_TexCoords2: return "TexCoords2"sv; + case VES_TexCoords3: return "TexCoords3"sv; case VES_Binormal: return "Binormal"sv; case VES_Tangent: return "Tangent"sv; case VES_Generic: return "Generic"sv; @@ -30,7 +33,10 @@ Tags::VertexElementSemantic Tags::FindVertexElementSemantic(std::string_view nam if (name == "Normal"sv) return VES_Normal; if (name == "Color1"sv) return VES_Color1; if (name == "Color2"sv) return VES_Color2; - if (name == "Texture_coordinates"sv) return VES_Texture_coordinates; + if (name == "Color3"sv) return VES_Color3; + if (name == "TexCoords1"sv) return VES_TexCoords1; + if (name == "TexCoords2"sv) return VES_TexCoords2; + if (name == "TexCoords3"sv) return VES_TexCoords3; if (name == "Binormal"sv) return VES_Binormal; if (name == "Tangent"sv) return VES_Tangent; if (name == "Generic"sv) return VES_Generic; @@ -86,6 +92,86 @@ int Tags::SizeOf(VertexElementType type) { return 0; } +int Tags::VectorLenOf(VertexElementType type) { + switch (type) { + case VET_Float1: + case VET_Double1: + case VET_Int1: + case VET_Uint1: + return 1; + case VET_Float2: + case VET_Double2: + case VET_Short2: + case VET_Short2Norm: + case VET_Ushort2: + case VET_Ushort2Norm: + case VET_Int2: + case VET_Uint2: + return 2; + case VET_Float3: + case VET_Double3: + case VET_Int3: + case VET_Uint3: + return 3; + case VET_Float4: + case VET_Double4: + case VET_Short4: + case VET_Short4Norm: + case VET_Ushort4: + case VET_Ushort4Norm: + case VET_Int4: + case VET_Uint4: + case VET_Byte4: + case VET_Byte4Norm: + case VET_Ubyte4: + case VET_Ubyte4Norm: + return 4; + } + return 0; +} + +GLenum Tags::FindGLType(VertexElementType type) { + switch (type) { + case VET_Float1: + case VET_Float2: + case VET_Float3: + case VET_Float4: + return GL_FLOAT; + case VET_Double1: + case VET_Double2: + case VET_Double3: + case VET_Double4: + return GL_DOUBLE; + case VET_Short2: + case VET_Short2Norm: + case VET_Short4: + case VET_Short4Norm: + return GL_SHORT; + case VET_Ushort2: + case VET_Ushort2Norm: + case VET_Ushort4: + case VET_Ushort4Norm: + return GL_UNSIGNED_SHORT; + case VET_Int1: + case VET_Int2: + case VET_Int3: + case VET_Int4: + return GL_INT; + case VET_Uint1: + case VET_Uint2: + case VET_Uint3: + case VET_Uint4: + return GL_UNSIGNED_INT; + case VET_Byte4: + case VET_Byte4Norm: + return GL_BYTE; + case VET_Ubyte4: + case VET_Ubyte4Norm: + return GL_UNSIGNED_BYTE; + } + return 0; +} + bool Tags::IsNormalized(VertexElementType type) { return type >= VET_NORM_BEGIN && type <= VET_NORM_END; } @@ -98,11 +184,18 @@ int Tags::SizeOf(IndexType type) { return 0; } -namespace ProjectBrussel_UNITY_ID { +GLenum Tags::FindGLType(IndexType type) { + switch (type) { + case IT_16Bit: return GL_UNSIGNED_SHORT; + case IT_32Bit: return GL_UNSIGNED_BYTE; + } + return GL_NONE; +} +namespace ProjectBrussel_UNITY_ID { struct GLTypeInfo { - absl::flat_hash_map<GLenum, std::string_view> enum2Name; - absl::flat_hash_map<std::string_view, GLenum> name2Enum; + robin_hood::unordered_flat_map<GLenum, std::string_view> enum2Name; + robin_hood::unordered_flat_map<std::string_view, GLenum> name2Enum; GLTypeInfo() { InsertEntry("float"sv, GL_FLOAT); |