|
cangine
|
Batches and draws untextured geometric primitives. More...
#include <primitive_renderer.hpp>

Public Member Functions | |
| PrimitiveRenderer (Shader *shader) | |
| Constructs the renderer with a shader. | |
| void | beginFrame () |
| Resets the batch at the start of a frame. | |
| void | endFrame () |
| Flushes the accumulated batch to the GPU. | |
| void | draw (const Triangle &t) |
| Adds a triangle to the current batch. | |
| void | draw (const Rectangle &t) |
| Adds a rectangle to the current batch. | |
| void | setShader (Shader *shader) |
| Replaces the shader used for drawing. | |
Private Attributes | |
| std::vector< Vertex > | vertices |
| Accumulated vertices for the current frame. | |
| VAO | vao |
| Vertex array describing the layout. | |
| VBO | vbo |
| Vertex buffer holding the batched data. | |
| Shader * | shader |
| Shader used to draw the primitives. | |
Static Private Attributes | |
| static PrimitiveRenderer * | instance = nullptr |
| Singleton instance. | |
Batches and draws untextured geometric primitives.
Accumulates triangle/rectangle vertices over a frame and submits them to the GPU as a single batch, using a supplied Shader.
| cangine::PrimitiveRenderer::PrimitiveRenderer | ( | Shader * | shader | ) |
Constructs the renderer with a shader.
| shader | Shader used for drawing primitives. |
| void cangine::PrimitiveRenderer::beginFrame | ( | ) |
Resets the batch at the start of a frame.
| void cangine::PrimitiveRenderer::draw | ( | const Rectangle & | t | ) |
Adds a rectangle to the current batch.
| t | Rectangle to draw. |
| void cangine::PrimitiveRenderer::draw | ( | const Triangle & | t | ) |
Adds a triangle to the current batch.
| t | Triangle to draw. |
| void cangine::PrimitiveRenderer::endFrame | ( | ) |
Flushes the accumulated batch to the GPU.
| void cangine::PrimitiveRenderer::setShader | ( | Shader * | shader | ) |
Replaces the shader used for drawing.
| shader | New shader to use. |
|
staticprivate |
Singleton instance.
|
private |
Accumulated vertices for the current frame.