TextRenderable Class
High-level text component that can be attached to game objects. More...
Declaration
Base class
| class | Renderable |
|
Abstract base class for objects that can be rendered by the rendering system. More... | |
Public Constructors Index
| TextRenderable (std::unique_ptr< helios::rendering::text::TextMesh > textMesh, std::shared_ptr< const helios::rendering::text::TextRenderPrototype > renderPrototype, const std::optional< helios::rendering::text::TextShaderPropertiesOverride > &textShaderPropertiesOverride=std::nullopt) | |
|
Constructs a TextRenderable with the given text mesh and configuration. More... | |
Public Member Functions Index
| std::optional< helios::rendering::text::TextShaderPropertiesOverride > | textShaderPropertiesOverride () noexcept |
|
Returns the optional shader properties override. More... | |
| void | setTextShaderPropertiesOverride (helios::rendering::text::TextShaderPropertiesOverride textShaderPropertiesOverride) noexcept |
|
Sets the shader properties override. More... | |
| const helios::math::aabbf & | localAABB () const noexcept override |
|
Returns the local-space axis-aligned bounding box. More... | |
| void | setText (std::string text) noexcept |
|
Updates the text string. More... | |
| std::string_view | text () const noexcept |
|
Returns the current text string. More... | |
| std::shared_ptr< const helios::rendering::text::TextRenderPrototype > | shareTextRenderPrototype () const noexcept |
|
Returns the text render prototype. More... | |
| const helios::rendering::text::TextRenderPrototype & | textRenderPrototype () const noexcept |
|
Returns a const ref to the TextRenderPrototype used by this TextRenderable. More... | |
| const helios::rendering::text::TextMesh & | textMesh () const noexcept |
|
Returns the text mesh. More... | |
| helios::rendering::text::TextMesh & | textMesh () noexcept |
|
Returns a mutable reference to the text mesh. More... | |
| void | writeUniformValues (helios::rendering::shader::UniformValueMap &uniformValueMap) const noexcept override |
|
Writes uniform values to the given map. More... | |
| void | emit (helios::rendering::RenderQueue &renderQueue, helios::rendering::shader::UniformValueMap &objectUniformValues, helios::rendering::shader::UniformValueMap &materialUniformValues) const override |
|
Emits a text render command to the render queue. More... | |
Protected Member Attributes Index
| std::shared_ptr< const helios::rendering::text::TextRenderPrototype > | textRenderPrototype_ = nullptr |
|
Shared prototype containing shader and text properties. More... | |
| std::optional< helios::rendering::text::TextShaderPropertiesOverride > | textShaderPropertiesOverride_ |
|
Optional overrides for text shader properties. More... | |
| std::unique_ptr< helios::rendering::text::TextMesh > | textMesh_ |
|
Positioning and styling data (font, position, scale). More... | |
Description
High-level text component that can be attached to game objects.
`TextRenderable` represents a piece of text that can be rendered in the scene. It combines a `TextRenderPrototype` (shader and font configuration) with instance-specific data like the text string and positioning.
## Responsibilities
- Hold the text string to be rendered.
- Reference a shared `TextRenderPrototype` for shader and font settings.
- Store instance-specific `TextMesh` (position, scale, font).
- Allow property overrides via `TextShaderPropertiesOverride`.
## Usage
```cpp auto prototype = std::make_shared<TextRenderPrototype>(shader, textProps); TextMesh drawProps{FontId{1}, {100.0f, 200.0f}, 1.0f};
TextRenderable text("Score: 0", prototype, drawProps); text.setText("Score: 100"); // Update dynamically ```
- See Also
- See Also
- See Also
Definition at line 57 of file TextRenderable.ixx.
Public Constructors
TextRenderable()
| inline explicit |
Constructs a TextRenderable with the given text mesh and configuration.
- Parameters
-
textMesh Unique pointer to the text mesh containing text content, font, and layout data.
renderPrototype Shared prototype with shader and font configuration.
textShaderPropertiesOverride Optional overrides for shader properties (e.g., text color).
- Exceptions
-
std::invalid_argument If `renderPrototype` is null.
Definition at line 89 of file TextRenderable.ixx.
References textMesh, textMesh_, textRenderPrototype_, textShaderPropertiesOverride and textShaderPropertiesOverride_.
Public Member Functions
emit()
| inline virtual |
Emits a text render command to the render queue.
Creates a `TextRenderCommand` with the current text, prototype, and uniform values, then adds it to the render queue for processing by the `TextRenderer`.
- Parameters
-
renderQueue The render queue to emit the command to.
objectUniformValues Object-specific uniform values (e.g., model matrix).
materialUniformValues Material uniform values (will be merged with text properties).
Definition at line 224 of file TextRenderable.ixx.
References helios::rendering::RenderQueue::add, textMesh_, textRenderPrototype_ and writeUniformValues.
localAABB()
| inline nodiscard noexcept virtual |
Returns the local-space axis-aligned bounding box.
The AABB is computed based on the text layout and font metrics.
- Returns
Reference to the local-space AABB.
Definition at line 130 of file TextRenderable.ixx.
References textMesh_ and textRenderPrototype_.
setText()
| inline noexcept |
setTextShaderPropertiesOverride()
| inline noexcept |
Sets the shader properties override.
- Parameters
-
textShaderPropertiesOverride The override to apply.
Definition at line 119 of file TextRenderable.ixx.
References textShaderPropertiesOverride and textShaderPropertiesOverride_.
shareTextRenderPrototype()
| inline nodiscard noexcept |
Returns the text render prototype.
**PERF-NOTE:** This method returns a copy of the `shared_ptr`, triggering atomic reference counting. For read-only access in rendering loops, consider using `textRenderPrototype_.get()` directly or adding a `const TextRenderPrototype&` overload.
- Returns
Shared pointer to the prototype.
Definition at line 162 of file TextRenderable.ixx.
Reference textRenderPrototype_.
text()
| inline nodiscard noexcept |
textMesh()
| inline nodiscard noexcept |
Returns the text mesh.
The text mesh contains the text content, font, and cached layout data.
- Returns
Reference to the text mesh.
Definition at line 185 of file TextRenderable.ixx.
Reference textMesh_.
Referenced by TextRenderable.
textMesh()
| inline nodiscard noexcept |
Returns a mutable reference to the text mesh.
- Returns
Mutable reference to the text mesh.
Definition at line 194 of file TextRenderable.ixx.
Reference textMesh_.
textRenderPrototype()
| inline nodiscard noexcept |
Returns a const ref to the TextRenderPrototype used by this TextRenderable.
This method provides direct access to the prototype without incrementing the reference count, making it suitable for use in hot rendering paths.
- Returns
A const ref to the TextRenderPrototype.
Definition at line 174 of file TextRenderable.ixx.
Reference textRenderPrototype_.
textShaderPropertiesOverride()
| inline nodiscard noexcept |
Returns the optional shader properties override.
- Returns
Optional containing the override if set.
Definition at line 110 of file TextRenderable.ixx.
Reference textShaderPropertiesOverride_.
Referenced by setTextShaderPropertiesOverride and TextRenderable.
writeUniformValues()
| inline noexcept virtual |
Writes uniform values to the given map.
Applies the prototype's text properties first, then any instance-specific overrides. Used by the render pipeline to configure the text shader.
- Parameters
-
uniformValueMap The map to write uniform values to.
Definition at line 206 of file TextRenderable.ixx.
References textRenderPrototype_ and textShaderPropertiesOverride_.
Referenced by emit.
Protected Member Attributes
textMesh_
| protected |
textRenderPrototype_
| protected |
Shared prototype containing shader and text properties.
Definition at line 64 of file TextRenderable.ixx.
Referenced by emit, localAABB, shareTextRenderPrototype, TextRenderable, textRenderPrototype and writeUniformValues.
textShaderPropertiesOverride_
| protected |
Optional overrides for text shader properties.
Definition at line 70 of file TextRenderable.ixx.
Referenced by setTextShaderPropertiesOverride, TextRenderable, textShaderPropertiesOverride and writeUniformValues.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.