From d43508ba4843801cbbf1f42a27af260d4eef5701 Mon Sep 17 00:00:00 2001 From: hnOsmium0001 Date: Sun, 17 Apr 2022 20:08:57 -0700 Subject: Initial work on sprites and texture system --- source/Material.hpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'source/Material.hpp') diff --git a/source/Material.hpp b/source/Material.hpp index 6b431be..bf1c988 100644 --- a/source/Material.hpp +++ b/source/Material.hpp @@ -6,6 +6,7 @@ #include "Texture.hpp" #include +#include #include #include #include @@ -15,11 +16,23 @@ #include #include +// TODO migrate material editor to Ires class MaterialManager; class Material : public RefCounted { public: // NOTE: public for internal helpers and editor // NOTE: specialize between scalar vs matrix vs vector to save memory + enum UniformType : uint16_t { + UT_Scalar, + UT_Vector, + UT_Matrix, + }; + + struct UniformIndex { + UniformType type; + uint16_t index; + }; + struct ScalarUniform { union { float floatValue; @@ -27,14 +40,14 @@ public: // NOTE: public for internal helpers and editor uint32_t uintValue; }; GLenum actualType; - /* Saves 'name' */ int infoUniformIndex; + /* Transient */ int infoUniformIndex; /* Transient */ GLint location; }; struct VectorUniform { float value[4]; int actualLength; - /* Saves 'name' */ int infoUniformIndex; + /* Transient */ int infoUniformIndex; /* Transient */ GLint location; }; @@ -42,13 +55,13 @@ public: // NOTE: public for internal helpers and editor float value[16]; int actualWidth; int actualHeight; - /* Saves 'name' */ int infoUniformIndex; + /* Transient */ int infoUniformIndex; /* Transient */ GLint location; }; struct TextureUniform { RcPtr value; - /* Saves 'name' */ int infoUniformIndex; + /* Transient */ int infoUniformIndex; /* Transient */ GLint location; }; @@ -61,9 +74,8 @@ public: // NOTE: public for internal helpers and editor std::vector mBoundTextures; public: - // NOTE: constructs invalid object - Material() = default; - Material(Shader* shader, std::string name = ""); + Material(); + Material(std::string name); void SetFloat(const char* name, float value); void SetInt(const char* name, int32_t value); @@ -106,7 +118,7 @@ public: static inline MaterialManager* instance = nullptr; private: - absl::flat_hash_map> mMaterials; + robin_hood::unordered_map> mMaterials; public: void DiscoverMaterials(); -- cgit v1.2.3-70-g09d2