PrimitiveRenderer class
Handles basic drawing of 'primitives' or geometric 2D objects.
Public static functions
- static void Init()
- Initializes the renderer to be ready for use.
- static void Shutdown()
- Shuts down the renderer and frees any allocated resources.
- static void StartBatch(const glm::mat4& view_projection)
- Starts a batch for submitting primitives to be drawn (called at the beginning of a frame).
- static void FinalizeBatch()
- 'Finishes' the batch of primitives to be drawn preparing the data for rendering.
- static void RenderBatch()
- Makes the actual GL calls to render the submitted primitives to the screen.
- static auto GetTextureSlot(unsigned int texture_id) -> int
- Gets the texture slot for a given texture ID.
- static void SubmitQuad(const glm::vec2& position, const glm::vec2& size, const glm::vec4& color, float rotation = 0.0f, const glm::vec2& origin = {0.0f, 0.0f})
- Submits a colored rectangle (quad) to be drawn at the specified position and size.
- static void SubmitTexturedQuad(const glm::vec2& position, const glm::vec2& size, unsigned int texture_id, const glm::vec4& color, float rotation = 0.0f, const glm::vec2& origin = {0.0f, 0.0f}, bool flip_uv = false)
- Submits a textured rectangle (quad) to be drawn at the specified position and size.
Function documentation
static void engine:: graphics:: PrimitiveRenderer:: StartBatch(const glm::mat4& view_projection)
Starts a batch for submitting primitives to be drawn (called at the beginning of a frame).
| Parameters | |
|---|---|
| view_projection | The view-projection matrix for the batch. |
static int engine:: graphics:: PrimitiveRenderer:: GetTextureSlot(unsigned int texture_id)
Gets the texture slot for a given texture ID.
| Parameters | |
|---|---|
| texture_id | The OpenGL texture ID. |
| Returns | The slot index. |
static void engine:: graphics:: PrimitiveRenderer:: SubmitQuad(const glm::vec2& position,
const glm::vec2& size,
const glm::vec4& color,
float rotation = 0.0f,
const glm::vec2& origin = {0.0f, 0.0f})
Submits a colored rectangle (quad) to be drawn at the specified position and size.
| Parameters | |
|---|---|
| position | The position of the rectangle's top-left corner. |
| size | The size of the rectangle. |
| color | The RGBA color of the rectangle. |
| rotation | The amount to rotate the quad in degrees. |
| origin | The origin point for rotation (relative to size, 0-1). |
static void engine:: graphics:: PrimitiveRenderer:: SubmitTexturedQuad(const glm::vec2& position,
const glm::vec2& size,
unsigned int texture_id,
const glm::vec4& color,
float rotation = 0.0f,
const glm::vec2& origin = {0.0f, 0.0f},
bool flip_uv = false)
Submits a textured rectangle (quad) to be drawn at the specified position and size.
| Parameters | |
|---|---|
| position | The position of the rectangle's top-left corner. |
| size | The size of the rectangle. |
| texture_id | The OpenGL texture ID to use. |
| color | The RGBA color (tint) of the rectangle. |
| rotation | The amount to rotate the quad in degrees. |
| origin | The origin point for rotation (relative to size, 0-1). |
| flip_uv | Whether to flip the way the textured quad is rendered. |