From 60ccc62f4934e44ad5b905fdbcf458302b8d8a09 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Fri, 3 Jun 2022 23:26:44 -0700 Subject: Changeset: 63 [WIP] Rename directories --- source/30-game/Material.hpp | 125 -------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 source/30-game/Material.hpp (limited to 'source/30-game/Material.hpp') diff --git a/source/30-game/Material.hpp b/source/30-game/Material.hpp deleted file mode 100644 index f1cd7dd..0000000 --- a/source/30-game/Material.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#pragma once - -#include "Ires.hpp" -#include "RcPtr.hpp" -#include "Shader.hpp" -#include "Texture.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Forward declarations -class Material; -class IresMaterial; - -class Material : public RefCounted { - friend class IresMaterial; - -public: - // 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; - int32_t intValue; - uint32_t uintValue; - }; - GLenum actualType; - /* Transient */ int infoUniformIndex; - /* Transient */ GLint location; - }; - - struct VectorUniform { - float value[4]; - int actualLength; - /* Transient */ int infoUniformIndex; - /* Transient */ GLint location; - }; - - struct MatrixUniform { - float value[16]; - int actualWidth; - int actualHeight; - /* Transient */ int infoUniformIndex; - /* Transient */ GLint location; - }; - - struct TextureUniform { - RcPtr value; - /* Transient */ int infoUniformIndex; - /* Transient */ GLint location; - }; - - IresMaterial* mIres = nullptr; - RcPtr mShader; - std::vector mBoundScalars; - std::vector mBoundVectors; - std::vector mBoundMatrices; - std::vector mBoundTextures; - -public: - Material(); - - void SetFloat(const char* name, float value); - void SetInt(const char* name, int32_t value); - void SetUInt(const char* name, uint32_t value); - - /// Instanciated for length == 1, 2, 3, 4 - template - void SetVector(const char* name, const glm::vec& vec); - - /// Instanciated for sizes (2,2) (3,3) (4,4) (2,3) (3,2) (2,4) (4,2) (3,4) (4,3) - template - void SetMatrix(const char* name, const glm::mat& mat); - - void SetTexture(const char* name, Texture* texture); - - std::span GetVectors() const; - std::span GetMatrices() const; - std::span GetTextures() const; - Shader* GetShader() const; - void SetShader(Shader* shader); - - IresMaterial* GetIres() const { return mIres; } - - bool IsValid() const; - - void UseUniforms() const; -}; - -// Initialized in main() -inline RcPtr gDefaultMaterial; - -class IresMaterial : public IresObject { -private: - RcPtr mInstance; - -public: - IresMaterial(); - - Material* GetInstance() const; - void InvalidateInstance(); - - void ShowEditor(IEditor& editor) override; - - void Write(IresWritingContext& ctx, rapidjson::Value& value, rapidjson::Document& root) const override; - void Read(IresLoadingContext& ctx, const rapidjson::Value& value) override; -}; -- cgit v1.2.3-70-g09d2