![]() |
Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
|
Base class representing a renderable scene. More...
#include <scene.hpp>
Public Member Functions | |
| Scene (SceneManager &sceneManager) | |
| Constructs a Scene instance associated with a SceneManager. More... | |
| ~Scene ()=default | |
| Virtual destructor for safe polymorphic destruction. More... | |
| virtual void | Initialize () |
| Initializes scene resources and drawables. More... | |
| virtual void | Update (float deltaTime) |
| Updates all objects within the scene. More... | |
| virtual void | Draw () |
| Renders all 3D and 2D drawables in the scene. More... | |
| virtual void | Shutdown () |
| Releases scene-specific resources and prepares for shutdown. More... | |
| SceneManager & | GetSceneManager () |
| Gets a reference to the SceneManager that owns this scene. More... | |
| void | LoadScene (std::string newSceneName) |
| Requests to load another scene. More... | |
| std::shared_ptr< Camera > | GetActiveCamera3D () |
| Returns the active 3D camera of the scene. More... | |
| std::shared_ptr< Camera2D > | GetActiveCamera2D () |
| Returns the active 2D camera of the scene. More... | |
| template<typename T , typename V > | |
| T * | Spawn (V arg) |
| Spawns and registers a drawable of type T. More... | |
| template<typename T > | |
| T * | SpawnActor () |
| Spawns and registers a 3D actor of type T. More... | |
| template<typename T > | |
| T * | SpawnActor2D () |
| Spawns and registers a 2D actor of type T. More... | |
| template<> | |
| StaticMesh * | Spawn (StaticMeshParams param) |
| template<> | |
| StaticMesh * | Spawn (StaticMeshParams param) |
Protected Member Functions | |
| void | DestroyDrawable3D (Drawable3D *drawable3D) |
| Schedules a 3D drawable for deferred destruction. More... | |
| void | DestroyDrawable2D (Drawable2D *drawable2D) |
| Schedules a 2D drawable for deferred destruction. More... | |
| void | DestroyActor (Actor *actor) |
| Schedules a 3D actor for deferred destruction. More... | |
| void | DestroyActor (Actor2D *actor2D) |
| Schedules a 2D actor for deferred destruction. More... | |
| void | SetBackgroundColor (glm::vec3 color) |
| Sets the scene background clear color. More... | |
Friends | |
| class | Drawable3D |
| class | Drawable2D |
| class | Actor |
| class | Actor2D |
Base class representing a renderable scene.
A Scene acts as a container for drawable objects (2D and 3D) and defines the update and draw lifecycle of a game or rendering context.
Derived scene classes should override Initialize(), Update(), and Draw() to implement specific logic and populate the drawable lists.
The Scene implements a deferred destruction mechanism to guarantee safe removal of actors and drawables during update and render passes. All objects spawned via the Scene are owned and lifetime-managed by it.
| rendering_engine::Scene::Scene | ( | SceneManager & | sceneManager | ) |
Constructs a Scene instance associated with a SceneManager.
| sceneManager | Reference to the SceneManager that owns this Scene. |
Definition at line 19 of file scene.cpp.
|
default |
Virtual destructor for safe polymorphic destruction.
|
protected |
Schedules a 3D actor for deferred destruction.
The actor is not destroyed immediately. Instead, it is placed into a pending destruction queue and safely removed during the next Scene update cycle.
This ensures that destruction does not invalidate iterators or interfere with the current update/draw pass.
| actor | Pointer to the actor to destroy. |
Definition at line 159 of file scene.cpp.
|
protected |
Schedules a 2D actor for deferred destruction.
Mirrors DestroyActor(Actor*) but operates on the 2D actor list. The actor will be safely shut down and deleted during the next flush phase.
| actor2D | Pointer to the 2D actor to destroy. |
Definition at line 164 of file scene.cpp.
|
protected |
|
protected |
|
virtual |
Renders all 3D and 2D drawables in the scene.
The base implementation can iterate through mDrawables3D and mDrawables2D to call each object�s Draw() method, using the active cameras.
Definition at line 85 of file scene.cpp.
| std::shared_ptr< Camera2D > rendering_engine::Scene::GetActiveCamera2D | ( | ) |
| std::shared_ptr< Camera > rendering_engine::Scene::GetActiveCamera3D | ( | ) |
| SceneManager & rendering_engine::Scene::GetSceneManager | ( | ) |
Gets a reference to the SceneManager that owns this scene.
Definition at line 129 of file scene.cpp.
|
virtual |
Initializes scene resources and drawables.
Called once when the scene becomes active. Derived classes should override this to load assets and create objects.
Definition at line 25 of file scene.cpp.
| void rendering_engine::Scene::LoadScene | ( | std::string | newSceneName | ) |
Requests to load another scene.
| newSceneName | The name of the registered scene to load next. |
This function delegates to SceneManager::LoadScene().
Definition at line 134 of file scene.cpp.
|
protected |
Sets the scene background clear color.
| color | Linear-space RGB color. |
Definition at line 220 of file scene.cpp.
|
virtual |
Releases scene-specific resources and prepares for shutdown.
Called when the scene is being unloaded or replaced.
Definition at line 104 of file scene.cpp.
| StaticMesh * rendering_engine::Scene::Spawn | ( | StaticMeshParams | param | ) |
| StaticMesh * rendering_engine::Scene::Spawn | ( | StaticMeshParams | param | ) |
Definition at line 41 of file spawn_drawables.hpp.
| T * rendering_engine::Scene::Spawn | ( | V | arg | ) |
Spawns and registers a drawable of type T.
All drawables must be created via this function to ensure correct Scene-level ownership and lifecycle management. Creation logic is provided by explicit template specializations.
| T | Drawable type. |
| V | Construction argument type. |
| arg | Construction argument. |
|
inline |
Spawns and registers a 3D actor of type T.
The actor is:
The Scene manages the full lifecycle of the actor, including deferred destruction and Shutdown() invocation.
| T | Type deriving from Actor. |
Definition at line 262 of file scene.hpp.
|
inline |
Spawns and registers a 2D actor of type T.
The actor is:
This function mirrors SpawnActor() but operates in the 2D domain. 2D actors use SceneComponent2D for hierarchical transformations.
| T | Type deriving from Actor2D. |
Definition at line 275 of file scene.hpp.
|
virtual |
Updates all objects within the scene.
| deltaTime | Time elapsed since the last frame (in milliseconds). |
Called once per frame. Override to implement per-frame logic such as animation, physics updates, or scene transitions.
Definition at line 45 of file scene.cpp.
|
friend |
|
friend |