CG-Project2
Loading...
Searching...
No Matches
State Class Reference

This class allow to create a state to be attached to the StateManager. A State works like a scene: defines all the meshes that will be rendered or not, defines custom behaviour while updating mesh data or while rendering meshes. More...

#include <State.hpp>

Inheritance diagram for State:

Public Member Functions

virtual void onAttach ()
 This method is called after using StateManager::sync() (read StateMnaager::sync() documentation for more info). It should contain all the operations that must be done before you start the execution of a State.
virtual void onDetach ()
 This method is called while using sync() (read sync() documentation for more info). It should contain all the operations that must be done at the end of State execution before deleting or changing State, it is automatically called by sync().
virtual void onUpdate ()
 This methods contains all the operations executed at every event::loop::LOOP_UPDATE if there are any.
virtual void onRender ()
 This methods contains all the operations executed at every event::loop::LOOP_RENDER if there are any.
virtual bool isCurrentStateEnd ()
 Retrieves the current binary state of the current State
std::string getName () const
 Retrieves the State name.
bool isAttached () const
 Retrieves if the state is attached.
 State (const std::string &name="State")
 Instances a state with the given name.

Protected Attributes

const std::string m_name
 state's name
bool m_attached = false
 true if the state is attached

Detailed Description

This class allow to create a state to be attached to the StateManager. A State works like a scene: defines all the meshes that will be rendered or not, defines custom behaviour while updating mesh data or while rendering meshes.

This is an abstract class it needs to be extended and override the methods that the child State will use.

It can be used to create scenes with meshes, lights, skybox etc. A State can have custom behaviour while updating and rendering, every "static" mesh must be initialized in State::onAttach() implementation.

Note
This application when executed will load a state loader (scene picker), where the user choose which state (scene) will be loaded.

Constructor & Destructor Documentation

◆ State()

State::State ( const std::string & name = "State")
inline

Instances a state with the given name.

Note
Each state need a name to be cached in the StateManager.

@params name the state's name

Member Function Documentation

◆ getName()

std::string State::getName ( ) const
inline

Retrieves the State name.

Returns
a strng with the state's name

◆ isAttached()

bool State::isAttached ( ) const
inline

Retrieves if the state is attached.

Returns
true if the state is attached

◆ isCurrentStateEnd()

virtual bool State::isCurrentStateEnd ( )
inlinevirtual

Retrieves the current binary state of the current State

Returns
bool true if the state is finished

Reimplemented in BootstrapState, and NormalViewState.

◆ onAttach()

virtual void State::onAttach ( )
inlinevirtual

This method is called after using StateManager::sync() (read StateMnaager::sync() documentation for more info). It should contain all the operations that must be done before you start the execution of a State.

Also this method need to be called in child class implementation using State::onAttach()

Reimplemented in BootstrapState, and NormalViewState.

◆ onDetach()

virtual void State::onDetach ( )
inlinevirtual

This method is called while using sync() (read sync() documentation for more info). It should contain all the operations that must be done at the end of State execution before deleting or changing State, it is automatically called by sync().

Also this method need to be called in child class implementation using State::onDetach()

Reimplemented in BootstrapState, and NormalViewState.

◆ onRender()

virtual void State::onRender ( )
inlinevirtual

This methods contains all the operations executed at every event::loop::LOOP_RENDER if there are any.

Reimplemented in BootstrapState, and NormalViewState.

◆ onUpdate()

virtual void State::onUpdate ( )
inlinevirtual

This methods contains all the operations executed at every event::loop::LOOP_UPDATE if there are any.

Reimplemented in BootstrapState, and NormalViewState.


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