Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
batchrenderer2d.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstddef>
4 
5 #include "../renderables/renderable2d.h"
6 #include "renderer2d.h"
7 
8 #include "../../utils/glassert.h"
9 
10 namespace fireworks { namespace graphics {
11 
12 #define RENDERER_MAX_SPRITES 60000
13 #define RENDERER_VERTEX_SIZE sizeof(VertexData)
14 #define RENDERER_SPRITE_SIZE RENDERER_VERTEX_SIZE * 4
15 #define RENDERER_BUFFER_SIZE RENDERER_SPRITE_SIZE * RENDERER_MAX_SPRITES
16 #define RENDERER_INDICES_SIZE RENDERER_MAX_SPRITES * 6
17 
19  class BatchRenderer2D : public Renderer2D
20  {
21  public:
24  private:
25  GLuint m_VAO;
26  GLuint m_VBO;
27  VertexData* m_Buffer;
28  IndexBuffer* m_IBO;
29  GLsizei m_IndicesCount;
30  std::vector<GLuint> m_TextureSlots;
31  GLushort quad_indices[RENDERER_INDICES_SIZE];
32  public:
39  BatchRenderer2D(Camera2D* camera2D, Shader* shader);
41 
43  void begin() override;
45  void submit(const Renderable2D* renderable) override;
47  void end() override;
49  void flush() override;
50  private:
51  void init();
52  };
53 
54 } }
void submit(const Renderable2D *renderable) override
Begins to submit the renderables to render queue.
Definition: batchrenderer2d.cpp:72
void end() override
Ends the submission and prepares the renderer to start drawing.
Definition: batchrenderer2d.cpp:160
Creates Index Buffers.
Definition: indexbuffer.h:11
Renders the renderables in a single draw call using batching.
Definition: batchrenderer2d.h:19
The Class responsible for drawing the basic Renderable objects onto the screen.
Definition: renderable2d.h:36
void flush() override
Draws the data processed onto the screen.
Definition: batchrenderer2d.cpp:166
The structure of the Vertex Data.
Definition: renderable2d.h:17
~BatchRenderer2D()
Definition: batchrenderer2d.cpp:22
Definition: audioclip.cpp:3
The class responsible for creating amazing shaders.
Definition: Shader.h:22
Shader * m_Shader
The shader with which the batch will be rendered with.
Definition: batchrenderer2d.h:23
Forward declaration of the graphics::Renderable2D.
Definition: renderer2d.h:15
BatchRenderer2D(Camera2D *camera2D, Shader *shader)
Creates the batch renderer.
Definition: batchrenderer2d.cpp:7
void begin() override
Begins the rendering process.
Definition: batchrenderer2d.cpp:66
The eye of the 2D world.
Definition: camera2d.h:11
#define RENDERER_INDICES_SIZE
Definition: batchrenderer2d.h:16