aboutsummaryrefslogtreecommitdiff
path: root/source/Material.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Material.hpp')
-rw-r--r--source/Material.hpp28
1 files changed, 20 insertions, 8 deletions
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 <glad/glad.h>
+#include <robin_hood.h>
#include <cstddef>
#include <cstdint>
#include <filesystem>
@@ -15,11 +16,23 @@
#include <string_view>
#include <vector>
+// 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<Texture> 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<TextureUniform> 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<std::string_view, RcPtr<Material>> mMaterials;
+ robin_hood::unordered_map<std::string_view, RcPtr<Material>> mMaterials;
public:
void DiscoverMaterials();