CG-Project2
Loading...
Searching...
No Matches
EcsScene.hpp
1#pragma once
2
3#include <map>
4
5#include <vector>
6
7#include "../../../Opengl-Core/include/Core.hpp"
8
13class BasicScene {
14public:
22 void init(const Shared<ogl::Camera> &mainCamera) { this->mainCamera = mainCamera; }
23
29 Shared<ogl::Camera> getCamera() const { return this->mainCamera; }
30
43 void addEntity(Shared<ogl::ShaderProgram> &shader, const unsigned int &ett);
44
52 void removeEntity(Shared<ogl::ShaderProgram> &shader, const unsigned int &ett);
53
61 void removeEntity(const unsigned int &ett);
62
69 std::map<Shared<ogl::ShaderProgram>, std::vector<unsigned int>> getShaderEntityMap() const { return this->m_entities; }
70
71 BasicScene(BasicScene &other) = delete;
72
73 void operator=(const BasicScene &other) = delete;
74
81 inline static Shared<BasicScene> instance() {
82 if (s_pointer == nullptr) {
83 Shared<BasicScene> copy(new BasicScene());
84 copy.swap(s_pointer);
85 }
86 return s_pointer;
87 }
88
89 ~BasicScene() = default;
90
91private:
93 std::map<Shared<ogl::ShaderProgram>, std::vector<unsigned int>> m_entities{};
94
96 Shared<ogl::Camera> mainCamera{};
97
99 inline static Shared<BasicScene> s_pointer = nullptr;
100
102 BasicScene() = default;
103};
This class is used to manage a scene with meshes that will be rendered. It's implemented using Single...
Definition EcsScene.hpp:13
std::map< Shared< ogl::ShaderProgram >, std::vector< unsigned int > > getShaderEntityMap() const
Returns the scene map with key ogl::ShaderProgram shared pointer and a vector of entity ids (Shared<o...
Definition EcsScene.hpp:69
Shared< ogl::Camera > getCamera() const
Retrieves the world camera shared pointer.
Definition EcsScene.hpp:29
void addEntity(Shared< ogl::ShaderProgram > &shader, const unsigned int &ett)
Adds an entity to the scene that will be rendered using the corresponding shader program.
Definition EcsScene.cpp:5
void removeEntity(Shared< ogl::ShaderProgram > &shader, const unsigned int &ett)
Removes the given entity from the scene with the corresponding shader, to optimize entity search proc...
Definition EcsScene.cpp:12
void init(const Shared< ogl::Camera > &mainCamera)
Initialize the current scene by setting the given world camera.
Definition EcsScene.hpp:22
static Shared< BasicScene > instance()
Retrieves the instance of the BasicScene. If it's not instanced, it will be instanced automatically.
Definition EcsScene.hpp:81