Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
renderer2d.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 // GLEW
5 #include <GL/glew.h>
6 
7 #include "../camera2d.h"
8 #include "../Shader.h"
9 
10 namespace fireworks { namespace graphics {
11 
12  class Renderable2D;
13 
15  class Renderer2D
16  {
17  public:
20  protected:
22  std::vector<glm::mat4> m_TransformationStack;
24  const glm::mat4* m_TransformationBack;
25  // GLuint m_FontTexture;
26  protected:
30  Renderer2D(Camera2D* camera2D)
31  : m_Camera2D(camera2D)
32  {
33  m_TransformationStack.push_back(glm::mat4(1.0f));
34  m_TransformationBack = &m_TransformationStack.back();
35  }
36  public:
38  void push(const glm::mat4& matrix, bool override = false)
39  {
40  if(override)
41  m_TransformationStack.push_back(matrix);
42  else
43  m_TransformationStack.push_back(m_TransformationStack.back() * matrix);
44 
45  m_TransformationBack = &m_TransformationStack.back();
46  }
48  void pop()
49  {
50  // TODO: Add to logging system
51  if(m_TransformationStack.size() > 1)
52  m_TransformationStack.pop_back();
53 
54  m_TransformationBack = &m_TransformationStack.back();
55  }
56 
57  virtual ~Renderer2D() { }
59  virtual void begin() {}
61  virtual void submit(const Renderable2D* renderable) = 0;
63  virtual void end() {}
65  virtual void flush() = 0;
66  };
67 
68 } }
The Class responsible for drawing the basic Renderable objects onto the screen.
Definition: renderable2d.h:36
virtual void flush()=0
Draws the data processed onto the screen.
const glm::mat4 * m_TransformationBack
The transformation matrix to renders stuff relative to one another aka if using groups.
Definition: renderer2d.h:24
Definition: audioclip.cpp:3
virtual ~Renderer2D()
Definition: renderer2d.h:57
virtual void submit(const Renderable2D *renderable)=0
Begins to submit the renderables to render queue.
void push(const glm::mat4 &matrix, bool override=false)
Pushes the transformation matrix to transform the renderables if using groups.
Definition: renderer2d.h:38
virtual void begin()
Begins the rendering process.
Definition: renderer2d.h:59
virtual void end()
Ends the submission and prepares the renderer to start drawing.
Definition: renderer2d.h:63
Renderer2D(Camera2D *camera2D)
Creates the renderer using the camera.
Definition: renderer2d.h:30
Forward declaration of the graphics::Renderable2D.
Definition: renderer2d.h:15
The eye of the 2D world.
Definition: camera2d.h:11
Camera2D * m_Camera2D
The camera to which the renderers out will be displayed to.
Definition: renderer2d.h:19
void pop()
Pops the transformation matrix to transform the renderables if using groups.
Definition: renderer2d.h:48
std::vector< glm::mat4 > m_TransformationStack
The transformation matrix stack that keeps track of relative transformation matrix of the groups...
Definition: renderer2d.h:22