#ifndef PHONG_MATERIAL_HPP
#define PHONG_MATERIAL_HPP
#include "Cache.hpp"
#include "Material.hpp"
#include <unordered_map>
namespace wren {
class PhongMaterial : public Material {
public:
WrMaterialType type() const override { return WR_MATERIAL_PHONG; }
void setTexture(Texture *texture, size_t index) override;
static PhongMaterial *createMaterial();
static void deleteMaterial(PhongMaterial *material);
static size_t cachedItemCount() { return PhongMaterial::cCache.size(); }
static void printCacheContents();
void clearMaterial() override;
void setColor(const glm::vec3 &color) override;
void setAmbient(const glm::vec3 &ambient, bool linearColor);
void setDiffuse(const glm::vec3 &diffuse, bool linearColor);
void setSpecular(const glm::vec3 &specular);
void setEmissive(const glm::vec3 &emissive);
void setShininess(float shininess);
void setSpecularExponent(float specularExponent);
void setTransparency(float transparency) override;
void setAllParameters(const glm::vec3 &ambient, const glm::vec3 &diffuse, const glm::vec3 &specular,
const glm::vec3 &emissive, float shininess, float transparency);
void setColorPerVertex(bool enabled) override { mColorPerVertex = enabled; }
void bind(bool bindProgram = true) const override;
size_t sortingId() const override;
void updateTranslucency() override;
private:
PhongMaterial();
~PhongMaterial();
void init();
static std::unordered_map<cache::Key, cache::PhongMaterialData> cCache;
void updateUniforms() const override;
void releaseMaterial() override;
void updateMaterial(const GlslLayout::PhongMaterial &material);
bool mColorPerVertex;
cache::Key mCacheKey;
cache::PhongMaterialData *mCacheData;
};
}
#endif