Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
fireworks::graphics::Renderable2D Class Reference

The Class responsible for drawing the basic Renderable objects onto the screen. More...

#include <renderable2d.h>

Inheritance diagram for fireworks::graphics::Renderable2D:
Collaboration diagram for fireworks::graphics::Renderable2D:

Public Member Functions

 Renderable2D (glm::vec3 position, glm::vec2 size, glm::vec4 color, Primitive2D primitive2d)
 Creates the renderable. More...
 
 Renderable2D (glm::vec3 position, glm::vec2 size, glm::vec4 color, Primitive2D primitive2d, Shader *shader)
 Creates the renderable. More...
 
virtual ~Renderable2D ()
 
virtual void submit (Renderer2D *renderer) const
 Virtual overload of the submit function, customize the way you can submit the renderable to the renderer. More...
 
template<typename T >
void AddComponent (components::Component *component)
 Template methods of various ways of adding components to the renderable. More...
 
template<>
void AddComponent (components::Component *component)
 The Rigidbody2D overload template. More...
 
const glm::vec3 & getPosition () const
 Gets the position of the Renderable. More...
 
const float & getRotation () const
 Gets the rotation of the Renderable. More...
 
const glm::vec2 & getSize () const
 Gets the size of the renderable. More...
 
const glm::vec4 & getColor () const
 Gets the color of the renderable. More...
 
const Primitive2D getPrimitive () const
 Gets the primitive shape that is used to draw the renderable. More...
 
const std::vector< glm::vec2 > & getUV () const
 Gets the UV coordinates of the 2D Renderable. More...
 
const TexturegetTexture () const
 Gets the texture that is used to draw the renderable. More...
 
const GLuint getTID () const
 Gets the ID of the renderables texture. More...
 
void flipX ()
 Flip the Renderable along the X-axis. More...
 
void unflipX ()
 Unflip the Renderable along the X-axis. More...
 
void flipY ()
 Flip the Renderable along the Y-axis. More...
 
void unflipY ()
 Unflip the Renderable along the X-axis. More...
 

Public Attributes

std::uint32_t objectID
 The unique ID of the renderable object. More...
 
Shadershader
 The Shader used to draw the particular renderable. More...
 
bool flippedX
 tells whether or not the renderable is flipped on the X-axis or not More...
 
bool flippedY
 tells whether or not the renderable is flipped on the Y-axis or not More...
 
std::vector< components::Component * > components
 The collection of Components that is attached to the renderable. More...
 

Protected Member Functions

 Renderable2D ()
 Create an empty renderable. More...
 
virtual void addedRigidBody2D ()
 Component callback functions. More...
 

Protected Attributes

glm::vec2 m_Size
 The size of the renderable. More...
 
glm::vec3 m_Position
 The position of the renderable. More...
 
glm::vec4 m_Color
 The color of the renderable. More...
 
float m_Rotation
 The rotation of the renderable along the Z-Axis. More...
 
Primitive2D m_Primitive2D
 The primitive that is used to draw the renderable. More...
 
std::vector< glm::vec2 > m_UV
 The UV coordinates of the renderable. More...
 
Texturem_Texture
 The texture (if any) used by the renderable. More...
 

Detailed Description

The Class responsible for drawing the basic Renderable objects onto the screen.

Every renderable type is derived from this class

Constructor & Destructor Documentation

◆ Renderable2D() [1/3]

fireworks::graphics::Renderable2D::Renderable2D ( glm::vec3  position,
glm::vec2  size,
glm::vec4  color,
Primitive2D  primitive2d 
)
inline

Creates the renderable.

Parameters
positionThe position of the renderable
sizeThe Size of the renderable
colorThe color of the renderable The primitive shape of the renderable (Quad or Triangle)
Note
This overload is to be used with graphics::BatchRenderer2D

◆ Renderable2D() [2/3]

fireworks::graphics::Renderable2D::Renderable2D ( glm::vec3  position,
glm::vec2  size,
glm::vec4  color,
Primitive2D  primitive2d,
Shader shader 
)
inline

Creates the renderable.

Parameters
positionThe position of the renderable
sizeThe Size of the renderable
colorThe color of the renderable The primitive shape of the renderable (Quad or Triangle)
shaderThe shader with which the renderable is to be rendered with
Note
This overload is to be used with graphics::BatchRenderer2D

◆ ~Renderable2D()

virtual fireworks::graphics::Renderable2D::~Renderable2D ( )
inlinevirtual

◆ Renderable2D() [3/3]

fireworks::graphics::Renderable2D::Renderable2D ( )
inlineprotected

Create an empty renderable.

Member Function Documentation

◆ AddComponent() [1/2]

template<typename T >
void fireworks::graphics::Renderable2D::AddComponent ( components::Component component)
inline

Template methods of various ways of adding components to the renderable.

Parameters
componentThe component to add to the renderable

◆ AddComponent() [2/2]

template<>
void fireworks::graphics::Renderable2D::AddComponent ( components::Component component)
inline

The Rigidbody2D overload template.

◆ addedRigidBody2D()

virtual void fireworks::graphics::Renderable2D::addedRigidBody2D ( )
inlineprotectedvirtual

Component callback functions.

Reimplemented in fireworks::graphics::Sprite.

◆ flipX()

void fireworks::graphics::Renderable2D::flipX ( )
inline

Flip the Renderable along the X-axis.

◆ flipY()

void fireworks::graphics::Renderable2D::flipY ( )
inline

Flip the Renderable along the Y-axis.

◆ getColor()

const glm::vec4& fireworks::graphics::Renderable2D::getColor ( ) const
inline

Gets the color of the renderable.

◆ getPosition()

const glm::vec3& fireworks::graphics::Renderable2D::getPosition ( ) const
inline

Gets the position of the Renderable.

Checks the components and returns the proper position after making necessary calculations and conditional analysis

◆ getPrimitive()

const Primitive2D fireworks::graphics::Renderable2D::getPrimitive ( ) const
inline

Gets the primitive shape that is used to draw the renderable.

◆ getRotation()

const float& fireworks::graphics::Renderable2D::getRotation ( ) const
inline

Gets the rotation of the Renderable.

Checks the components and returns the proper rotation after making necessary calculations and conditional analysis

◆ getSize()

const glm::vec2& fireworks::graphics::Renderable2D::getSize ( ) const
inline

Gets the size of the renderable.

◆ getTexture()

const Texture* fireworks::graphics::Renderable2D::getTexture ( ) const
inline

Gets the texture that is used to draw the renderable.

◆ getTID()

const GLuint fireworks::graphics::Renderable2D::getTID ( ) const
inline

Gets the ID of the renderables texture.

◆ getUV()

const std::vector<glm::vec2>& fireworks::graphics::Renderable2D::getUV ( ) const
inline

Gets the UV coordinates of the 2D Renderable.

◆ submit()

virtual void fireworks::graphics::Renderable2D::submit ( Renderer2D renderer) const
inlinevirtual

Virtual overload of the submit function, customize the way you can submit the renderable to the renderer.

Reimplemented in fireworks::graphics::Group.

◆ unflipX()

void fireworks::graphics::Renderable2D::unflipX ( )
inline

Unflip the Renderable along the X-axis.

◆ unflipY()

void fireworks::graphics::Renderable2D::unflipY ( )
inline

Unflip the Renderable along the X-axis.

Member Data Documentation

◆ components

std::vector<components::Component*> fireworks::graphics::Renderable2D::components

The collection of Components that is attached to the renderable.

◆ flippedX

bool fireworks::graphics::Renderable2D::flippedX

tells whether or not the renderable is flipped on the X-axis or not

◆ flippedY

bool fireworks::graphics::Renderable2D::flippedY

tells whether or not the renderable is flipped on the Y-axis or not

◆ m_Color

glm::vec4 fireworks::graphics::Renderable2D::m_Color
protected

The color of the renderable.

◆ m_Position

glm::vec3 fireworks::graphics::Renderable2D::m_Position
protected

The position of the renderable.

◆ m_Primitive2D

Primitive2D fireworks::graphics::Renderable2D::m_Primitive2D
protected

The primitive that is used to draw the renderable.

◆ m_Rotation

float fireworks::graphics::Renderable2D::m_Rotation
protected

The rotation of the renderable along the Z-Axis.

◆ m_Size

glm::vec2 fireworks::graphics::Renderable2D::m_Size
protected

The size of the renderable.

◆ m_Texture

Texture* fireworks::graphics::Renderable2D::m_Texture
protected

The texture (if any) used by the renderable.

◆ m_UV

std::vector<glm::vec2> fireworks::graphics::Renderable2D::m_UV
mutableprotected

The UV coordinates of the renderable.

◆ objectID

std::uint32_t fireworks::graphics::Renderable2D::objectID

The unique ID of the renderable object.

◆ shader

Shader* fireworks::graphics::Renderable2D::shader

The Shader used to draw the particular renderable.

Note
This shader is used only when using the graphics::InstanceRenderer2D Renderer, unlike for the graphics::BatchRenderer2D which used a global shader for all the renderables

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