Khaotic Engine Reborn
Loading...
Searching...
No Matches
ecs::ShaderComponent Class Reference
Inheritance diagram for ecs::ShaderComponent:
ecs::Component

Public Member Functions

 ShaderComponent ()
 
void Initialize () override
 
void Update (float deltaTime) override
 
ShaderType GetActiveShader () const
 
void SetActiveShader (ShaderType shader)
 
- Public Member Functions inherited from ecs::Component
 Component (const Component &)=delete
 
Componentoperator= (const Component &)=delete
 
 Component (Component &&)=default
 
Componentoperator= (Component &&)=default
 

Static Public Member Functions

static ShaderType StringToShaderType (const std::string &str)
 
static std::string ShaderTypeToString (ShaderType type)
 

Detailed Description

Definition at line 24 of file shader_component.h.

Constructor & Destructor Documentation

◆ ShaderComponent()

ecs::ShaderComponent::ShaderComponent ( )
inline

Builder for the ShaderComponent class. Initializes the active shader to LIGHTING by default.

Definition at line 31 of file shader_component.h.

31: m_activeShader(ShaderType::LIGHTING) {}

Member Function Documentation

◆ GetActiveShader()

ShaderType ecs::ShaderComponent::GetActiveShader ( ) const
inline

Get the currently active shader type.

Returns
The active shader type as a ShaderType enum.

Definition at line 41 of file shader_component.h.

41{ return m_activeShader; }

◆ Initialize()

void ecs::ShaderComponent::Initialize ( )
inlineoverridevirtual

Virtual function to initialize the component.

Reimplemented from ecs::Component.

Definition at line 34 of file shader_component.h.

34{}

◆ SetActiveShader()

void ecs::ShaderComponent::SetActiveShader ( ShaderType shader)
inline

Set the active shader type. This method allows changing the shader type used for rendering.

Parameters
shaderThe shader type to set as a ShaderType enum.

Definition at line 47 of file shader_component.h.

47{ m_activeShader = shader; }

◆ ShaderTypeToString()

static std::string ecs::ShaderComponent::ShaderTypeToString ( ShaderType type)
inlinestatic

Convert a ShaderType enum to its string representation. This method provides a string name for each shader type.

Parameters
typeThe shader type as a ShaderType enum.
Returns
The name of the shader type as a string.

Definition at line 75 of file shader_component.h.

75 {
76 switch (type) {
77 case ShaderType::ALPHA_MAPPING: return "ALPHA_MAPPING";
78 case ShaderType::CEL_SHADING: return "CEL_SHADING";
79 case ShaderType::NORMAL_MAPPING: return "NORMAL_MAPPING";
80 case ShaderType::SPECULAR_MAPPING: return "SPECULAR_MAPPING";
81 case ShaderType::TEXTURE: return "TEXTURE";
82 case ShaderType::LIGHTING: return "LIGHTING";
83 case ShaderType::SUNLIGHT: return "SUNLIGHT";
84 case ShaderType::SKYBOX: return "SKYBOX";
85 case ShaderType::REFLECTION: return "REFLECTION";
86 case ShaderType::REFRACTION: return "REFRACTION";
87 default: return "TEXTURE";
88 }
89 }

◆ StringToShaderType()

static ShaderType ecs::ShaderComponent::StringToShaderType ( const std::string & str)
inlinestatic

Set the active shader type from a string. This method converts a string representation of a shader type to the corresponding ShaderType enum.

Parameters
shaderNameThe name of the shader type as a string.
Returns
The ShaderType enum corresponding to the provided string.

Definition at line 55 of file shader_component.h.

55 {
56 if (str == "ALPHA_MAPPING") return ShaderType::ALPHA_MAPPING;
57 if (str == "CEL_SHADING") return ShaderType::CEL_SHADING;
58 if (str == "NORMAL_MAPPING") return ShaderType::NORMAL_MAPPING;
59 if (str == "SPECULAR_MAPPING") return ShaderType::SPECULAR_MAPPING;
60 if (str == "TEXTURE") return ShaderType::TEXTURE;
61 if (str == "LIGHTING") return ShaderType::LIGHTING;
62 if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
63 if (str == "SKYBOX") return ShaderType::SKYBOX;
64 if (str == "REFLECTION") return ShaderType::REFLECTION;
65 if (str == "REFRACTION") return ShaderType::REFRACTION;
66 return ShaderType::TEXTURE;
67 }

◆ Update()

void ecs::ShaderComponent::Update ( float deltaTime)
inlineoverridevirtual

Virtual function to update the component.

Parameters
deltaTimeTime since the last update.

Reimplemented from ecs::Component.

Definition at line 35 of file shader_component.h.

35{}

The documentation for this class was generated from the following file: