# Khaotic Engine Reborn: ecs::ShaderComponent Class Reference

Loading...
Searching...
No Matches
ecs::ShaderComponent Class Reference
Inheritance diagram for ecs::ShaderComponent:

## 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
Component & | operator= (const Component &)=delete
| Component (Component &&)=default
Component & | operator= (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.

: 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.

{ 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.

{}

## SetActiveShader()

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

inline

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

Parameters

  shader | The shader type to set as a ShaderType enum.

Definition at line 47 of file shader_component.h.

{ 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

  type | The 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.

{
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";
}
}

## 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

  shaderName | The 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.

{
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;
}

## Update()

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

inlineoverridevirtual

Virtual function to update the component.

Parameters

  deltaTime | Time since the last update.

Reimplemented from ecs::Component.

Definition at line 35 of file shader_component.h.

{}

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

- enginecustom/src/inc/system/ecs/components/shader_component.h