aboutsummaryrefslogtreecommitdiff
path: root/source/Material.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-04-18 20:59:57 -0700
committerrtk0c <[email protected]>2022-04-18 20:59:57 -0700
commit07e8754e4d799e44678b595177e79e6eaa621268 (patch)
tree6d9d4470259776ef01e814191ba0440f83505933 /source/Material.hpp
parent7f871b04470766f0f5266cf949b65a54b7a6f79e (diff)
Changeset: 11 Migrate Material to Ires
Diffstat (limited to 'source/Material.hpp')
-rw-r--r--source/Material.hpp62
1 files changed, 12 insertions, 50 deletions
diff --git a/source/Material.hpp b/source/Material.hpp
index 469cb7b..7cf5603 100644
--- a/source/Material.hpp
+++ b/source/Material.hpp
@@ -1,24 +1,20 @@
#pragma once
-#include "EditorAttachment.hpp"
+#include "Ires.hpp"
#include "RcPtr.hpp"
#include "Shader.hpp"
#include "Texture.hpp"
-// #include "Ires.hpp"
#include <glad/glad.h>
#include <robin_hood.h>
#include <cstddef>
#include <cstdint>
-#include <filesystem>
#include <glm/glm.hpp>
#include <memory>
#include <span>
#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
@@ -66,8 +62,6 @@ public: // NOTE: public for internal helpers and editor
/* Transient */ GLint location;
};
- std::string mName;
- std::unique_ptr<EditorAttachment> mEditorAttachment;
RcPtr<Shader> mShader;
std::vector<ScalarUniform> mBoundScalars;
std::vector<VectorUniform> mBoundVectors;
@@ -76,7 +70,6 @@ public: // NOTE: public for internal helpers and editor
public:
Material();
- Material(std::string name);
void SetFloat(const char* name, float value);
void SetInt(const char* name, int32_t value);
@@ -97,58 +90,27 @@ public:
std::span<const TextureUniform> GetTextures() const;
Shader* GetShader() const;
void SetShader(Shader* shader);
- const std::string& GetName() const;
- bool IsAnnoymous() const;
bool IsValid() const;
void UseUniforms() const;
- EditorAttachment* GetEditorAttachment() const { return mEditorAttachment.get(); }
- void SetEditorAttachment(EditorAttachment* attachment) { mEditorAttachment.reset(attachment); }
-
- void GetDesignatedPath(char* buffer, int bufferSize);
- std::filesystem::path GetDesignatedPath();
-
- bool SaveToFile(const std::filesystem::path& filePath) const;
- bool LoadFromFile(const std::filesystem::path& filePath);
+ bool Write(rapidjson::Value& value, rapidjson::Document& root) const;
+ bool Read(const rapidjson::Value& value);
};
-// class IresMaterial : public IresObject {
-// public:
-// RcPtr<Material> mInstance;
-
-// public:
-// IresMaterial()
-// : IresObject(KD_Spritesheet) {}
-
-// bool IsValid() const;
-
-// Material* CreateInstance() const;
-// Material* GetInstance();
-// void InvalidateInstance();
-
-// void ShowEditor() override;
-
-// void Write(rapidjson::Value& value, rapidjson::Document& root) const override;
-// void Read(const rapidjson::Value& value) override;
-// };
-
-class MaterialManager {
-public:
- static inline MaterialManager* instance = nullptr;
-
+class IresMaterial : public IresObject {
private:
- robin_hood::unordered_map<std::string_view, RcPtr<Material>> mMaterials;
+ RcPtr<Material> mInstance;
public:
- void DiscoverMaterials();
+ IresMaterial();
+
+ Material* GetInstance() const;
+ void InvalidateInstance();
- std::pair<Material*, bool> SaveMaterial(Material* mat);
- void DeleteMaterial(Material* mat, bool onDisk = false);
- Material* LoadMaterial(std::string_view name);
- bool RenameMaterial(Material* mat, std::string newName);
+ void ShowEditor(EditorInstance& editor) override;
- const auto& GetMaterials() const { return mMaterials; }
- Material* FindMaterial(std::string_view name);
+ void Write(rapidjson::Value& value, rapidjson::Document& root) const override;
+ void Read(const rapidjson::Value& value) override;
};