Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
scene.hpp
Go to the documentation of this file.
1// This file is part of the Rendering Engine project.
2// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3// Copyright (c) 2025 Alexander Obzherin
4// Distributed under the terms of the zlib License. See LICENSE.md for details.
5
6#pragma once
7
8#include <memory>
9#include <vector>
10#include <string>
11
13
14namespace rendering_engine
15{
16class SceneManager;
17class Camera;
18class Camera2D;
19class Drawable3D;
20class Drawable2D;
21
22/**
23 * @class Scene
24 * @brief Base class representing a renderable scene.
25 *
26 * A Scene acts as a container for drawable objects (2D and 3D) and defines
27 * the update and draw lifecycle of a game or rendering context.
28 *
29 * Derived scene classes should override Initialize(), Update(), and Draw()
30 * to implement specific logic and populate the drawable lists.
31 *
32 * @note Scenes are created and managed by SceneManager.
33 * @see SceneManager, Drawable3D, Drawable2D, Camera, Camera2D
34 */
36{
37public:
38 /**
39 * @brief Constructs a Scene instance associated with a SceneManager.
40 * @param sceneManager Reference to the SceneManager that owns this Scene.
41 */
42 Scene(SceneManager& sceneManager);
43 /**
44 * @brief Virtual destructor for safe polymorphic destruction.
45 */
46 ~Scene() = default;
47 /**
48 * @brief Initializes scene resources and drawables.
49 *
50 * Called once when the scene becomes active.
51 * Derived classes should override this to load assets and create objects.
52 */
53 virtual void Initialize();
54 /**
55 * @brief Updates all objects within the scene.
56 * @param deltaTime Time elapsed since the last frame (in milliseconds).
57 *
58 * Called once per frame. Override to implement per-frame logic such as
59 * animation, physics updates, or scene transitions.
60 */
61 virtual void Update(float deltaTime);
62 /**
63 * @brief Renders all 3D and 2D drawables in the scene.
64 *
65 * The base implementation can iterate through mDrawables3D and mDrawables2D
66 * to call each object�s Draw() method, using the active cameras.
67 */
68 virtual void Draw();
69 /**
70 * @brief Releases scene-specific resources and prepares for shutdown.
71 *
72 * Called when the scene is being unloaded or replaced.
73 */
74 virtual void Shutdown();
75 /**
76 * @brief Gets a reference to the SceneManager that owns this scene.
77 * @return Reference to the owning SceneManager.
78 */
80 /**
81 * @brief Requests to load another scene.
82 * @param newSceneName The name of the registered scene to load next.
83 *
84 * This function delegates to SceneManager::LoadScene().
85 */
86 void LoadScene(std::string newSceneName);
87
88protected:
90
91 std::shared_ptr<Camera> mActiveCamera3D;
92 std::shared_ptr<Camera2D> mActiveCamera2D;
93
94 std::vector<Drawable3D*> mDrawables3D;
95 std::vector<Drawable2D*> mDrawables2D;
96};
97
98} // namespace rendering_engine
Represents a 2D camera with position, rotation, and zoom control.
Definition camera_2d.hpp:36
Represents a 3D perspective camera with world transform and projection settings.
Definition camera.hpp:48
2D drawable component for rendering objects in 2D space.
3D drawable component for rendering objects in 3D space.
std::shared_ptr< Camera > mActiveCamera3D
Definition scene.hpp:91
virtual void Shutdown()
Releases scene-specific resources and prepares for shutdown.
Definition scene.cpp:59
std::vector< Drawable3D * > mDrawables3D
Definition scene.hpp:94
virtual void Update(float deltaTime)
Updates all objects within the scene.
Definition scene.cpp:20
void LoadScene(std::string newSceneName)
Requests to load another scene.
Definition scene.cpp:76
SceneManager & GetSceneManager()
Gets a reference to the SceneManager that owns this scene.
Definition scene.cpp:71
std::vector< Drawable2D * > mDrawables2D
Definition scene.hpp:95
virtual void Initialize()
Initializes scene resources and drawables.
Definition scene.cpp:16
SceneManager & mSceneManager
Definition scene.hpp:89
~Scene()=default
Virtual destructor for safe polymorphic destruction.
Scene(SceneManager &sceneManager)
Constructs a Scene instance associated with a SceneManager.
Definition scene.cpp:11
std::shared_ptr< Camera2D > mActiveCamera2D
Definition scene.hpp:92
virtual void Draw()
Renders all 3D and 2D drawables in the scene.
Definition scene.cpp:41
Manages scenes, resource caches, and scene transitions within the rendering engine.
#define RE_API