Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
rendering_engine::Scene Class Reference

Base class representing a renderable scene. More...

#include <scene.hpp>

Public Member Functions

 Scene (SceneManager &sceneManager)
 Constructs a Scene instance associated with a SceneManager.
 ~Scene ()=default
 Virtual destructor for safe polymorphic destruction.
virtual void Initialize ()
 Initializes scene resources and drawables.
virtual void Update (float deltaTime)
 Updates all objects within the scene.
virtual void Draw ()
 Renders all 3D and 2D drawables in the scene.
virtual void Shutdown ()
 Releases scene-specific resources and prepares for shutdown.
SceneManagerGetSceneManager ()
 Gets a reference to the SceneManager that owns this scene.
void LoadScene (std::string newSceneName)
 Requests to load another scene.

Protected Attributes

SceneManagermSceneManager
std::shared_ptr< CameramActiveCamera3D
std::shared_ptr< Camera2DmActiveCamera2D
std::vector< Drawable3D * > mDrawables3D
std::vector< Drawable2D * > mDrawables2D

Detailed Description

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.

Note
Scenes are created and managed by SceneManager.
See also
SceneManager, Drawable3D, Drawable2D, Camera, Camera2D

Definition at line 35 of file scene.hpp.

Constructor & Destructor Documentation

◆ Scene()

rendering_engine::Scene::Scene ( SceneManager & sceneManager)

Constructs a Scene instance associated with a SceneManager.

Parameters
sceneManagerReference to the SceneManager that owns this Scene.

Definition at line 11 of file scene.cpp.

12 :
13 mSceneManager(sceneManager)
14{}
SceneManager & mSceneManager
Definition scene.hpp:89

◆ ~Scene()

rendering_engine::Scene::~Scene ( )
default

Virtual destructor for safe polymorphic destruction.

Member Function Documentation

◆ Draw()

void rendering_engine::Scene::Draw ( )
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 41 of file scene.cpp.

42{
44 {
45 for (auto& drawable2D : mDrawables2D)
46 {
47 drawable2D->Draw(*mActiveCamera2D);
48 }
49 }
51 {
52 for (auto& drawable3D : mDrawables3D)
53 {
54 drawable3D->Draw(*mActiveCamera3D);
55 }
56 }
57}
std::shared_ptr< Camera > mActiveCamera3D
Definition scene.hpp:91
std::vector< Drawable3D * > mDrawables3D
Definition scene.hpp:94
std::vector< Drawable2D * > mDrawables2D
Definition scene.hpp:95
std::shared_ptr< Camera2D > mActiveCamera2D
Definition scene.hpp:92

◆ GetSceneManager()

SceneManager & rendering_engine::Scene::GetSceneManager ( )

Gets a reference to the SceneManager that owns this scene.

Returns
Reference to the owning SceneManager.

Definition at line 71 of file scene.cpp.

72{
73 return mSceneManager;
74}

◆ Initialize()

void rendering_engine::Scene::Initialize ( )
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 16 of file scene.cpp.

17{
18}

◆ LoadScene()

void rendering_engine::Scene::LoadScene ( std::string newSceneName)

Requests to load another scene.

Parameters
newSceneNameThe name of the registered scene to load next.

This function delegates to SceneManager::LoadScene().

Definition at line 76 of file scene.cpp.

77{
78 mSceneManager.LoadScene(newSceneName);
79}

◆ Shutdown()

void rendering_engine::Scene::Shutdown ( )
virtual

Releases scene-specific resources and prepares for shutdown.

Called when the scene is being unloaded or replaced.

Definition at line 59 of file scene.cpp.

60{
61 for (auto& drawable2D : mDrawables2D)
62 {
63 drawable2D->Shutdown();
64 }
65 for (auto& drawable3D : mDrawables3D)
66 {
67 drawable3D->Shutdown();
68 }
69}

◆ Update()

void rendering_engine::Scene::Update ( float deltaTime)
virtual

Updates all objects within the scene.

Parameters
deltaTimeTime 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 20 of file scene.cpp.

21{
23 {
24 mActiveCamera2D->Update(deltaTime);
25 }
27 {
28 //mActiveCamera3D->Update(deltaTime);
29 }
30
31 for (auto& drawable2D : mDrawables2D)
32 {
33 drawable2D->Update(deltaTime);
34 }
35 for (auto& drawable3D : mDrawables3D)
36 {
37 //drawable3D->Update(deltaTime);
38 }
39}

Member Data Documentation

◆ mActiveCamera2D

std::shared_ptr<Camera2D> rendering_engine::Scene::mActiveCamera2D
protected

Definition at line 92 of file scene.hpp.

◆ mActiveCamera3D

std::shared_ptr<Camera> rendering_engine::Scene::mActiveCamera3D
protected

Definition at line 91 of file scene.hpp.

◆ mDrawables2D

std::vector<Drawable2D*> rendering_engine::Scene::mDrawables2D
protected

Definition at line 95 of file scene.hpp.

◆ mDrawables3D

std::vector<Drawable3D*> rendering_engine::Scene::mDrawables3D
protected

Definition at line 94 of file scene.hpp.

◆ mSceneManager

SceneManager& rendering_engine::Scene::mSceneManager
protected

Definition at line 89 of file scene.hpp.


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