Skip to content

Components

Components hold per-entity data and logic. They are managed by the ComponentManager singleton and attached to entities via entity->add_component<T>(...).

CameraComponent

Manages the camera's projection and view matrices.

cpp
auto* cam_comp = entity->add_component<CameraComponent>(fov);

cam_comp->recalculate_projection_matrix(framebuffer);
cam_comp->recalculate_view_matrix();

glm::mat4 view = cam_comp->get_view_matrix();
glm::mat4 proj = cam_comp->get_projection_matrix();

Called every frame by GeometryPass for each Camera entity.

TransformComponent

Stores position, scale, and the derived model matrix.

cpp
auto* transform = entity->add_component<TransformComponent>();

transform->position = glm::vec3(1.0f, 0.0f, 0.0f);
transform->scale    = glm::vec3(1.0f);
// transform->matrix is updated by transform->update()

start() initializes internal state; update() recomputes matrix from position/scale/rotation each frame.

MeshComponent

Attaches a mesh (geometry data) to an entity for rendering.

cpp
auto* mesh = entity->add_component<MeshComponent>();

// Attach a loaded model by descriptor ID
mesh->attach_model("cube");

// Or attach a procedural mesh
mesh->attach_mesh(Mesh::quad(1.0f));
mesh->attach_mesh(Mesh::cube(2.0f));

// Lifecycle
mesh->start(render_target);   // uploads GPU buffers
mesh->update(render_target);  // issues draw calls

ResourceComponent

Binds a shader and optional textures/cubemaps to an entity.

cpp
auto* res = entity->add_component<ResourceComponent>();

res->attach_shader("my_shader");
res->set_shader("my_shader");            // switch at runtime
res->set_shader(descriptor_id);          // by ResourceDescriptorID

res->attach_cubemap({ cubemap_id, "_skybox" });

bool has = res->has_shader();
Shader* shader = res->shader();          // pointer to active shader

res->start();   // loads and binds initial resources
res->update();  // re-binds shader each frame

MaterialComponent

Uploads material parameters (textures, colors, PBR values) to the bound shader each frame.

cpp
auto* mat = entity->add_component<MaterialComponent>();
mat->update();  // called by GeometryPass

LightComponent

Computes and uploads lighting data from a chosen strategy (directional, point, spotlight).

cpp
auto* light = entity->add_component<LightComponent>(camera_entity_id);
light->strategy(create_scope<DirectionalStrategy>(direction, color, intensity));

// Called by GeometryPass for each object
light->update(object, light_index);

Light Strategies

ClassLight type
DirectionalStrategyInfinite directional light
PointStrategyPoint light with attenuation
SpotlightStrategySpotlight with cutoff angle

All strategies inherit from LightStrategy and implement the uniform upload logic.

PostProcessingComponent

Manages post-processing state for a PostProcessing entity.

cpp
auto* pp = entity->add_component<PostProcessingComponent>();
pp->start(render_target);
pp->post_update(render_target);  // binds scene color texture each frame

TagComponent

An optional string label attached to an entity for identification and serialization.

cpp
auto* tag = entity->add_component<TagComponent>("PlayerCube");

ResourceComponent (serialization)

All components support serialization through paired serializer classes (e.g., CameraComponentSerializer, TransformComponentSerializer). Serializers are registered on the SceneSerializer and called during scene->save() / scene->load().