This class is used to manage a scene with meshes that will be rendered. It's implemented using Singleton.
More...
#include <EcsScene.hpp>
|
void | init (const Shared< ogl::Camera > &mainCamera) |
| Initialize the current scene by setting the given world camera.
|
Shared< ogl::Camera > | getCamera () const |
| Retrieves the world camera shared pointer.
|
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.
|
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 process.
|
void | removeEntity (const unsigned int &ett) |
| Removes the given entity from the scene without knowing the corresponding shader.
|
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<ogl::Program, std::vector<unsigned int>).
|
| BasicScene (BasicScene &other)=delete |
void | operator= (const BasicScene &other)=delete |
|
static Shared< BasicScene > | instance () |
| Retrieves the instance of the BasicScene. If it's not instanced, it will be instanced automatically.
|
This class is used to manage a scene with meshes that will be rendered. It's implemented using Singleton.
◆ addEntity()
void BasicScene::addEntity |
( |
Shared< ogl::ShaderProgram > & | shader, |
|
|
const unsigned int & | ett ) |
Adds an entity to the scene that will be rendered using the corresponding shader program.
This method will store in a map of (ogl::ShaderProgram, std::vector<unsigned int>) the shader and the entity id. This allow the systems::render::renderAllMesh() method to call ogl::ShaderProgram::use() and then render all the meshes that uses that program. This way minimizes the number of calls to enable a shader program at each frame.
- Parameters
-
◆ getCamera()
Retrieves the world camera shared pointer.
- Returns
- the world ogl::Camera shared pointer
◆ getShaderEntityMap()
std::map< Shared< ogl::ShaderProgram >, std::vector< unsigned int > > BasicScene::getShaderEntityMap |
( |
| ) |
const |
|
inline |
Returns the scene map with key ogl::ShaderProgram shared pointer and a vector of entity ids (Shared<ogl::Program, std::vector<unsigned int>).
- Returns
- a map containing all the entities for each shader program
◆ init()
void BasicScene::init |
( |
const Shared< ogl::Camera > & | mainCamera | ) |
|
|
inline |
Initialize the current scene by setting the given world camera.
The camera will be used to send view and projection data to shaders.
- Parameters
-
mainCamera | the world camera pointer |
◆ instance()
Retrieves the instance of the BasicScene. If it's not instanced, it will be instanced automatically.
- Returns
- a Shared<BasicScene> object
◆ removeEntity() [1/2]
void BasicScene::removeEntity |
( |
const unsigned int & | ett | ) |
|
Removes the given entity from the scene without knowing the corresponding shader.
It iterate through all keys and find the entity, if it's in the map it will be erased.
- Parameters
-
◆ removeEntity() [2/2]
void BasicScene::removeEntity |
( |
Shared< ogl::ShaderProgram > & | shader, |
|
|
const unsigned int & | ett ) |
Removes the given entity from the scene with the corresponding shader, to optimize entity search process.
@params shader a ogl::ShaderProgram shared pointer @params ett entity id
The documentation for this class was generated from the following files: