Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Graphics::Renderable Class Reference

Class for renderable. More...

#include <renderable.h>

Inheritance diagram for Graphics::Renderable:
Component Events::Subject Events::Observer Graphics::UI::Element Graphics::UI::Area Graphics::UI::TextArea Graphics::UI::Button Graphics::UI::TextField Graphics::UI::QuitButton

Public Member Functions

 Renderable (const unsigned int vertex_array_object, const VertexData &vertex_data)
 Renderable constructor. More...
 
 Renderable (const Renderable &)=delete
 
Renderable operator= (Renderable &)=delete
 
 Renderable (Renderable &&renderable)
 
Renderableoperator= (Renderable &&renderable)
 
virtual ~Renderable ()
 
void setShader (std::shared_ptr< Shader > shader_object) noexcept
 Sets the shader. More...
 
std::shared_ptr< ShadergetShader () const noexcept
 Gets the shader. More...
 
void addTexture (const unsigned int unit, const std::string uniform_name, std::shared_ptr< BaseTexture > texture_object) noexcept
 Adds a texture. More...
 
void removeTexture (const unsigned int unit)
 Removes a texture. More...
 
std::map< unsigned int,
std::shared_ptr< BaseTexture > > 
getTextures () const noexcept
 Gets the textures. More...
 
void setLightReactive (const bool reactive) noexcept
 Sets if the renderable should be light reactive. More...
 
bool isLightReactive () const noexcept
 Determines if light reactive. More...
 
void setAmbientLight (const glm::vec3 color) noexcept
 Sets the ambient light. More...
 
glm::vec3 getAmbientLight () const noexcept
 Gets the ambient light. More...
 
void setAmbientIntensity (const float intensity) noexcept
 Sets the ambient intensity. More...
 
float getAmbientIntensity () const noexcept
 Gets the ambient intensity. More...
 
void addInfluencingLight (std::shared_ptr< Light > light) noexcept
 Adds an influencing light. More...
 
void clearInfluencingLights ()
 Clears all influencing lights. More...
 
virtual std::string to_string () const noexceptoverride
 Returns a string representation of the object. More...
 
virtual std::string className () const noexceptoverride
 Returns a string representing the class name. More...
 
float highestZ () const noexcept
 The highest possible z value in the renderable. More...
 
unsigned int getVertexArrayBinding () const noexcept
 Gets the vertex array binding. More...
 
VertexData getVertexData () const noexcept
 Gets the vertex data. More...
 
virtual void onDestroy () override
 Called when the engine is shutting down. More...
 
virtual void onStart () override
 Called when the engine starts and when a new scene is loaded. More...
 
virtual bool onUpdate (const double delta) override
 Called every engine loop. More...
 
void handleQueuedEvent (std::shared_ptr< Events::Event > event) override
 HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More...
 
void onNotifyNow (std::shared_ptr< Events::Event > event) override
 When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More...
 
virtual unsigned long long getValueForSorting () const noexceptoverride
 Gets the value for sorting. More...
 
virtual void log (el::base::type::ostream_t &os) const override
 
- Public Member Functions inherited from Component
 Component ()
 Component constructor. More...
 
void setTransform (std::shared_ptr< Transform > transform)
 Sets the transform. More...
 
std::shared_ptr< TransformgetTransform () const noexcept
 Gets the transform. More...
 
void setActive (const bool active) noexcept
 Sets the component active or inactive. More...
 
bool isActive () const noexcept
 Determines if active. More...
 
unsigned int getId () const noexcept
 Gets the identifier. More...
 
bool operator< (Component &other) noexcept
 Operator < using getValueForSorting. More...
 
virtual ~Component ()
 Destroys the object. More...
 
- Public Member Functions inherited from Events::Subject
virtual ~Subject ()=default
 
virtual void notify (std::shared_ptr< Event > event)
 notify is used to tell observers of an event. More...
 
virtual void notifyNow (std::shared_ptr< Event > event)
 notifyNow is used to tell observers of an event as an interrupt. More...
 
virtual void addObserver (std::shared_ptr< Observer > observer)
 Adds an observer. More...
 
virtual void removeObserver (std::shared_ptr< Observer > observer)
 Removes an observer. More...
 
- Public Member Functions inherited from Events::Observer
virtual ~Observer ()
 
void onNotify (std::shared_ptr< Event > event)
 When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More...
 
void processEventQueue ()
 This should be called once ever loop for every Observer to properly use queued events. More...
 

Static Public Member Functions

static std::shared_ptr
< Renderable
create (const VertexData &vertex_data)
 Renderable factory function. More...
 

Protected Member Functions

void setUniform (const Uniform &uniform) noexcept
 
 Renderable ()
 
- Protected Member Functions inherited from Events::Observer
std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 

Protected Attributes

std::set< Uniformuniforms
 
- Protected Attributes inherited from Component
std::weak_ptr< Entityentity
 
std::shared_ptr< Transformtransform
 
bool active
 
unsigned int id
 

Additional Inherited Members

- Static Protected Attributes inherited from Component
static unsigned int next_id = 0
 

Detailed Description

Class for renderable.

Constructor & Destructor Documentation

Graphics::Renderable::Renderable ( )
inlineprotected
Graphics::Renderable::Renderable ( const unsigned int  vertex_array_object,
const VertexData vertex_data 
)

Renderable constructor.

Parameters
[in]vertex_array_objectThe vertex array object
[in]vertex_dataThe vertex data
Graphics::Renderable::Renderable ( const Renderable )
delete
Graphics::Renderable::Renderable ( Renderable &&  renderable)
Graphics::Renderable::~Renderable ( )
virtual

References onDestroy().

Member Function Documentation

void Graphics::Renderable::addInfluencingLight ( std::shared_ptr< Light light)
noexcept

Adds an influencing light.

Parameters
[in]lightThe light

Referenced by generated::getRenderableModule().

void Graphics::Renderable::addTexture ( const unsigned int  unit,
const std::string  uniform_name,
std::shared_ptr< BaseTexture texture_object 
)
noexcept

Adds a texture.

Parameters
[in]unitThe unit
[in]uniform_nameThe uniform name
[in]texture_objectThe texture object

References Graphics::Uniform::setData().

Referenced by Graphics::UI::Element::Element(), and generated::getRenderableModule().

std::string Graphics::Renderable::className ( ) const
overridevirtualnoexcept

Returns a string representing the class name.

Returns
The class name

Reimplemented from Component.

Reimplemented in Graphics::UI::Element, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, Graphics::UI::Area, and Graphics::UI::QuitButton.

Referenced by generated::getRenderableModule().

void Graphics::Renderable::clearInfluencingLights ( )

Clears all influencing lights.

Referenced by generated::getRenderableModule().

std::shared_ptr< Renderable > Graphics::Renderable::create ( const VertexData vertex_data)
static

Renderable factory function.

Parameters
[in]vertex_dataThe vertex data
Returns
newly created Renderable

References Graphics::VertexData::generateVertexArrayObject().

float Graphics::Renderable::getAmbientIntensity ( ) const
noexcept

Gets the ambient intensity.

Returns
The ambient intensity.

Referenced by generated::getRenderableModule().

glm::vec3 Graphics::Renderable::getAmbientLight ( ) const
noexcept

Gets the ambient light.

Returns
The ambient light.

Referenced by generated::getRenderableModule().

std::shared_ptr< Shader > Graphics::Renderable::getShader ( ) const
noexcept

Gets the shader.

Returns
The shader.

Referenced by generated::getRenderableModule().

std::map< unsigned int, std::shared_ptr< BaseTexture > > Graphics::Renderable::getTextures ( ) const
noexcept

Gets the textures.

Returns
A map of texture units to textures

Referenced by generated::getRenderableModule().

unsigned long long Graphics::Renderable::getValueForSorting ( ) const
overridevirtualnoexcept

Gets the value for sorting.

Returns
The value for sorting.

Implements Component.

Reimplemented in Graphics::UI::Element.

References Component::getTransform().

unsigned int Graphics::Renderable::getVertexArrayBinding ( ) const
noexcept

Gets the vertex array binding.

Returns
The vertex array binding.
VertexData Graphics::Renderable::getVertexData ( ) const
noexcept

Gets the vertex data.

Returns
The vertex data.
void Graphics::Renderable::handleQueuedEvent ( std::shared_ptr< Events::Event event)
overridevirtual

HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.

Parameters
[in]eventThe event

Reimplemented from Component.

Reimplemented in Graphics::UI::Element, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, and Graphics::UI::Button.

References Events::ADD_TEXTURE, Component::handleQueuedEvent(), Events::REMOVE_TEXTURE, Events::SET_SHADER, Events::SET_UNIFORM, and setUniform().

Referenced by Graphics::UI::Element::handleQueuedEvent(), and onNotifyNow().

float Graphics::Renderable::highestZ ( ) const
noexcept

The highest possible z value in the renderable.

Returns
A float representing the highest z value in the renderable

References Graphics::VertexData::highestZ().

Referenced by to_string().

bool Graphics::Renderable::isLightReactive ( ) const
noexcept

Determines if light reactive.

Returns
True if light reactive, False otherwise.

Referenced by generated::getRenderableModule().

void Graphics::Renderable::log ( el::base::type::ostream_t &  os) const
overridevirtual
void Graphics::Renderable::onDestroy ( )
overridevirtual

Called when the engine is shutting down.

Implements Component.

Reimplemented in Graphics::UI::Element, Graphics::UI::TextField, Graphics::UI::TextArea, and Graphics::UI::Area.

Referenced by ~Renderable().

void Graphics::Renderable::onNotifyNow ( std::shared_ptr< Events::Event event)
overridevirtual

When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.

Parameters
[in]eventThe event

Reimplemented from Component.

Reimplemented in Graphics::UI::Element, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, and Graphics::UI::Button.

References handleQueuedEvent().

void Graphics::Renderable::onStart ( )
overridevirtual

Called when the engine starts and when a new scene is loaded.

Implements Component.

Reimplemented in Graphics::UI::Element, Graphics::UI::TextField, Graphics::UI::TextArea, and Graphics::UI::Area.

References Graphics::Uniform::setData(), and setUniform().

bool Graphics::Renderable::onUpdate ( const double  delta)
overridevirtual
Renderable Graphics::Renderable::operator= ( Renderable )
delete
Renderable & Graphics::Renderable::operator= ( Renderable &&  renderable)
void Graphics::Renderable::removeTexture ( const unsigned int  unit)

Removes a texture.

Parameters
[in]unitThe unit

Referenced by generated::getRenderableModule().

void Graphics::Renderable::setAmbientIntensity ( const float  intensity)
noexcept

Sets the ambient intensity.

Parameters
[in]intensityThe intensity

Referenced by generated::getRenderableModule().

void Graphics::Renderable::setAmbientLight ( const glm::vec3  color)
noexcept

Sets the ambient light.

Parameters
[in]colorThe color

Referenced by generated::getRenderableModule().

void Graphics::Renderable::setLightReactive ( const bool  reactive)
noexcept

Sets if the renderable should be light reactive.

Parameters
[in]reactiveTrue if reactive

Referenced by generated::getRenderableModule().

void Graphics::Renderable::setShader ( std::shared_ptr< Shader shader_object)
noexcept

Sets the shader.

Parameters
[in]shader_objectThe shader object

Referenced by Graphics::UI::Element::Element(), and generated::getRenderableModule().

void Graphics::Renderable::setUniform ( const Uniform uniform)
protectednoexcept
std::string Graphics::Renderable::to_string ( ) const
overridevirtualnoexcept

Returns a string representation of the object.

Returns
String representation of the object.

Reimplemented from Component.

Reimplemented in Graphics::UI::Element, Graphics::UI::TextArea, Graphics::UI::TextField, and Graphics::UI::Area.

References highestZ(), and Component::to_string().

Referenced by generated::getRenderableModule(), log(), and Graphics::UI::Element::to_string().

Member Data Documentation

std::set<Uniform> Graphics::Renderable::uniforms
protected

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