Batched renderer for textured quads (rectangles).
More...
#include <quad_renderer.hpp>
|
| | QuadRenderer (Shader *shader) |
| | Constructs the renderer with a shader.
|
| |
| void | beginFrame () |
| | Resets the batch at the start of a frame.
|
| |
| void | draw (const Transform &transform, const Rectangle &r, bool normalize=true) |
| | Adds a transformed rectangle to the current batch.
|
| |
| void | draw (const Rectangle &r, bool normalize=true) |
| | Adds a rectangle to the current batch.
|
| |
| void | flush () |
| | Submits the accumulated batch to the GPU.
|
| |
| void | setTexture (Texture *t, bool mono=false) |
| | Binds a texture for subsequent quads, flushing if it changes.
|
| |
| void | setShader (Shader *shader) |
| | Replaces the shader used for drawing.
|
| |
Batched renderer for textured quads (rectangles).
Accumulates up to MAX_QUADS quads per batch and renders them with a single draw call. Supports an optional bound texture and a monochrome mode used for glyph rendering.
◆ QuadRenderer()
| cangine::QuadRenderer::QuadRenderer |
( |
Shader * |
shader | ) |
|
Constructs the renderer with a shader.
- Parameters
-
| shader | Shader used for drawing quads. |
◆ beginFrame()
| void cangine::QuadRenderer::beginFrame |
( |
| ) |
|
Resets the batch at the start of a frame.
◆ draw() [1/2]
| void cangine::QuadRenderer::draw |
( |
const Rectangle & |
r, |
|
|
bool |
normalize = true |
|
) |
| |
Adds a rectangle to the current batch.
- Parameters
-
| r | Rectangle geometry to draw. |
| normalize | If true, positions are normalized to clip space. |
◆ draw() [2/2]
| void cangine::QuadRenderer::draw |
( |
const Transform & |
transform, |
|
|
const Rectangle & |
r, |
|
|
bool |
normalize = true |
|
) |
| |
Adds a transformed rectangle to the current batch.
- Parameters
-
| transform | Transform applied to the rectangle. |
| r | Rectangle geometry to draw. |
| normalize | If true, positions are normalized to clip space. |
◆ flush()
| void cangine::QuadRenderer::flush |
( |
| ) |
|
Submits the accumulated batch to the GPU.
◆ setShader()
| void cangine::QuadRenderer::setShader |
( |
Shader * |
shader | ) |
|
Replaces the shader used for drawing.
- Parameters
-
◆ setTexture()
| void cangine::QuadRenderer::setTexture |
( |
Texture * |
t, |
|
|
bool |
mono = false |
|
) |
| |
Binds a texture for subsequent quads, flushing if it changes.
- Parameters
-
| t | Texture to bind. |
| mono | If true, treat the texture as single-channel. |
◆ currentMono
| bool cangine::QuadRenderer::currentMono = false |
|
private |
Whether the bound texture is single-channel.
◆ currentTexture
| Texture* cangine::QuadRenderer::currentTexture = nullptr |
|
private |
Currently bound texture, if any.
◆ ebo
| EBO cangine::QuadRenderer::ebo |
|
private |
Index buffer for the quads.
◆ instance
◆ MAX_INDICES
| constexpr uint32_t cangine::QuadRenderer::MAX_INDICES = MAX_QUADS * 6 |
|
staticconstexprprivate |
Index capacity (6 per quad).
◆ MAX_QUADS
| constexpr uint32_t cangine::QuadRenderer::MAX_QUADS = 10000 |
|
staticconstexprprivate |
◆ MAX_VERTICES
| constexpr uint32_t cangine::QuadRenderer::MAX_VERTICES = MAX_QUADS * 4 |
|
staticconstexprprivate |
◆ quadCount
| uint32_t cangine::QuadRenderer::quadCount = 0 |
|
private |
Number of quads in the current batch.
◆ shader
| Shader* cangine::QuadRenderer::shader |
|
private |
Shader used to draw the quads.
◆ vao
| VAO cangine::QuadRenderer::vao |
|
private |
Vertex array describing the layout.
◆ vbo
| VBO cangine::QuadRenderer::vbo |
|
private |
Vertex buffer holding the batched data.
◆ vertices
| std::vector<Vertex> cangine::QuadRenderer::vertices |
|
private |
Accumulated vertices for the current batch.
The documentation for this class was generated from the following files: