#pragma once #include "RcPtr.hpp" #include "Shader.hpp" #include "Texture.hpp" #include #include #include #include #include #include #include #include // TODO support multiple sizes of vectors and matrices class Material : public RefCounted { public: struct ScalarUniform { union { float floatValue; int32_t intValue; uint32_t uintValue; }; GLenum actualType; GLint location; }; struct VectorUniform { float value[4]; int actualLength; GLint location; }; struct MatrixUniform { float value[16]; int actualWidth; int actualHeight; GLint location; }; struct TextureUniform { RcPtr value; GLint location; }; RcPtr mShader; std::vector mBoundScalars; std::vector mBoundVectors; std::vector mBoundMatrices; std::vector mBoundTextures; public: Material(Shader* shader); 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; const Shader& GetShader() const; void UseUniforms() const; };