# Khaotic Engine Reborn: enginecustom/src/inc/system/ecs/components/shader_component.h Source File

Loading...
Searching...
No Matches
shader_component.h
#pragma once
#include "../component.h"
namespace ecs {
enum class ShaderType
{
CEL_SHADING,
LIGHTING,
NORMAL_MAPPING,
SPECULAR_MAPPING,
REFLECTION,
REFRACTION,
TEXTURE,
SKYBOX,
SUNLIGHT,
ALPHA_MAPPING
};
class ShaderComponent : public Component {
public:
ShaderComponent() : m_activeShader(ShaderType::LIGHTING) {}
~ShaderComponent() = default;
void Initialize() override {}
void Update(float deltaTime) override {}
ShaderType GetActiveShader() const { return m_activeShader; }
void SetActiveShader(ShaderType shader) { m_activeShader = shader; }
static ShaderType StringToShaderType(const std::string& str) {
if (str == "ALPHA_MAPPING") return ShaderType::ALPHA_MAPPING;
if (str == "CEL_SHADING") return ShaderType::CEL_SHADING;
if (str == "NORMAL_MAPPING") return ShaderType::NORMAL_MAPPING;
if (str == "SPECULAR_MAPPING") return ShaderType::SPECULAR_MAPPING;
if (str == "TEXTURE") return ShaderType::TEXTURE;
if (str == "LIGHTING") return ShaderType::LIGHTING;
if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
if (str == "SKYBOX") return ShaderType::SKYBOX;
if (str == "REFLECTION") return ShaderType::REFLECTION;
if (str == "REFRACTION") return ShaderType::REFRACTION;
return ShaderType::TEXTURE;
}
static std::string ShaderTypeToString(ShaderType type) {
switch (type) {
case ShaderType::ALPHA_MAPPING: return "ALPHA_MAPPING";
case ShaderType::CEL_SHADING: return "CEL_SHADING";
case ShaderType::NORMAL_MAPPING: return "NORMAL_MAPPING";
case ShaderType::SPECULAR_MAPPING: return "SPECULAR_MAPPING";
case ShaderType::TEXTURE: return "TEXTURE";
case ShaderType::LIGHTING: return "LIGHTING";
case ShaderType::SUNLIGHT: return "SUNLIGHT";
case ShaderType::SKYBOX: return "SKYBOX";
case ShaderType::REFLECTION: return "REFLECTION";
case ShaderType::REFRACTION: return "REFRACTION";
default: return "TEXTURE";
}
}
private:
ShaderType m_activeShader;
};
} // namespace ecs
ecs::Component
Definition component.h:12
ecs::ShaderComponent
Definition shader_component.h:24
ecs::ShaderComponent::ShaderTypeToString
static std::string ShaderTypeToString(ShaderType type)
Definition shader_component.h:75
ecs::ShaderComponent::Update
void Update(float deltaTime) override
Definition shader_component.h:35
ecs::ShaderComponent::SetActiveShader
void SetActiveShader(ShaderType shader)
Definition shader_component.h:47
ecs::ShaderComponent::ShaderComponent
ShaderComponent()
Definition shader_component.h:31
ecs::ShaderComponent::Initialize
void Initialize() override
Definition shader_component.h:34
ecs::ShaderComponent::GetActiveShader
ShaderType GetActiveShader() const
Definition shader_component.h:41
ecs::ShaderComponent::StringToShaderType
static ShaderType StringToShaderType(const std::string &str)
Definition shader_component.h:55
ecs
Definition component.h:9
ecs::ShaderType
ShaderType
Definition shader_component.h:11