14 namespace fireworks {
namespace graphics {
63 mutable std::vector<glm::vec2>
m_UV;
67 static std::uint32_t m_UniqueID;
77 : m_Position(position), m_Size(size), m_Color(color), m_Primitive2D(primitive2d), shader(nullptr), m_Texture(nullptr), m_Rotation(0.0f)
79 objectID = ++m_UniqueID;
92 : m_Position(position), m_Size(size), m_Color(color), m_Primitive2D(primitive2d), shader(shader), m_Texture(nullptr), m_Rotation(0.0f)
94 objectID = ++m_UniqueID;
98 0, 1, 2, 3, 4, 5, 6, 7,
99 8, 9, 10, 11, 12, 13, 14, 15
118 template <
typename T>
121 components.push_back(component);
123 if ((dynamic_cast<physics::RigidBody2D*>(component)))
124 std::cout <<
"Added a rigibody2d component" << std::endl;
131 components.push_back(component);
133 std::cout <<
"Added a rigibody2d component in the rigidBody overload" << std::endl;
135 this->addedRigidBody2D();
147 inline const glm::vec2&
getSize()
const {
return m_Size; }
149 inline const glm::vec4&
getColor()
const {
return m_Color; }
153 inline const std::vector<glm::vec2>&
getUV()
const {
return m_UV; }
157 inline const GLuint
getTID()
const {
return m_Texture ==
nullptr ? 0 : m_Texture->
getID(); }
173 objectID = ++m_UniqueID;
184 m_UV.push_back(glm::vec2(0, 0));
185 m_UV.push_back(glm::vec2(0, 1));
186 m_UV.push_back(glm::vec2(1, 1));
187 m_UV.push_back(glm::vec2(1, 0));
192 m_UV.push_back(glm::vec2(0, 0));
193 m_UV.push_back(glm::vec2(0.5, 1));
194 m_UV.push_back(glm::vec2(1, 0));
197 void GetRigidBody2DPosition()
199 for (
int i = 0; i < components.size(); i++)
203 m_Position = rb->GetPositionInPixels();
209 void GetRigidBody2DRotation()
211 for (
int i = 0; i < components.size(); i++)
215 m_Rotation = rb->GetRotation();
const std::vector< glm::vec2 > & getUV() const
Gets the UV coordinates of the 2D Renderable.
Definition: renderable2d.h:153
std::vector< glm::vec2 > m_UV
The UV coordinates of the renderable.
Definition: renderable2d.h:63
void flipX()
Flip the Renderable along the X-axis.
Definition: renderable2d.h:161
glm::vec4 color
Definition: renderable2d.h:22
const Primitive2D getPrimitive() const
Gets the primitive shape that is used to draw the renderable.
Definition: renderable2d.h:151
void unflipY()
Unflip the Renderable along the X-axis.
Definition: renderable2d.h:167
virtual void submit(Renderer2D *renderer) const
Virtual overload of the submit function, customize the way you can submit the renderable to the rende...
Definition: renderable2d.h:110
glm::vec3 vertex
Definition: renderable2d.h:19
const glm::vec4 & getColor() const
Gets the color of the renderable.
Definition: renderable2d.h:149
Renderable2D()
Create an empty renderable.
Definition: renderable2d.h:171
RigidBody 2D Physics component to simulate real time physics.
Definition: rigidbody2d.h:27
The Class responsible for drawing the basic Renderable objects onto the screen.
Definition: renderable2d.h:36
The class responsible for loading Textures.
Definition: texture.h:11
glm::vec2 uv
Definition: renderable2d.h:20
Renderable2D(glm::vec3 position, glm::vec2 size, glm::vec4 color, Primitive2D primitive2d)
Creates the renderable.
Definition: renderable2d.h:76
glm::vec2 m_Size
The size of the renderable.
Definition: renderable2d.h:53
The structure of the Vertex Data.
Definition: renderable2d.h:17
Class for creating components.
Definition: component.h:22
glm::vec4 m_Color
The color of the renderable.
Definition: renderable2d.h:57
const GLuint getTID() const
Gets the ID of the renderables texture.
Definition: renderable2d.h:157
Definition: audioclip.cpp:3
const glm::vec3 & getPosition() const
Gets the position of the Renderable.
Definition: renderable2d.h:141
Shader * shader
The Shader used to draw the particular renderable.
Definition: renderable2d.h:44
virtual void submit(const Renderable2D *renderable)=0
Begins to submit the renderables to render queue.
const unsigned int getID() const
Gets the ID of the texture.
Definition: texture.h:40
float tid
Definition: renderable2d.h:21
std::vector< components::Component * > components
The collection of Components that is attached to the renderable.
Definition: renderable2d.h:50
The class responsible for creating amazing shaders.
Definition: Shader.h:22
virtual ~Renderable2D()
Definition: renderable2d.h:107
Primitive2D m_Primitive2D
The primitive that is used to draw the renderable.
Definition: renderable2d.h:61
void flipY()
Flip the Renderable along the Y-axis.
Definition: renderable2d.h:165
void enable()
Enables the shader.
Definition: Shader.cpp:119
float m_Rotation
The rotation of the renderable along the Z-Axis.
Definition: renderable2d.h:59
const float & getRotation() const
Gets the rotation of the Renderable.
Definition: renderable2d.h:145
Primitive2D
Different variations of primitives.
Definition: renderable2d.h:26
virtual void addedRigidBody2D()
Component callback functions.
Definition: renderable2d.h:178
Texture * m_Texture
The texture (if any) used by the renderable.
Definition: renderable2d.h:65
Renderable2D(glm::vec3 position, glm::vec2 size, glm::vec4 color, Primitive2D primitive2d, Shader *shader)
Creates the renderable.
Definition: renderable2d.h:91
Forward declaration of the graphics::Renderable2D.
Definition: renderer2d.h:15
void disable()
Disables the shader.
Definition: Shader.cpp:124
void AddComponent(components::Component *component)
Template methods of various ways of adding components to the renderable.
Definition: renderable2d.h:119
bool flippedX
tells whether or not the renderable is flipped on the X-axis or not
Definition: renderable2d.h:46
const Texture * getTexture() const
Gets the texture that is used to draw the renderable.
Definition: renderable2d.h:155
bool flippedY
tells whether or not the renderable is flipped on the Y-axis or not
Definition: renderable2d.h:48
std::uint32_t objectID
The unique ID of the renderable object.
Definition: renderable2d.h:40
void unflipX()
Unflip the Renderable along the X-axis.
Definition: renderable2d.h:163
glm::vec3 m_Position
The position of the renderable.
Definition: renderable2d.h:55
void setUniform1iv(const GLchar *name, int *value, GLsizei count)
Definition: Shader.cpp:94
const glm::vec2 & getSize() const
Gets the size of the renderable.
Definition: renderable2d.h:147