Skip to main content

TextRenderable Class

High-level text component that can be attached to game objects. More...

Declaration

class helios::rendering::text::TextRenderable { ... }

Base class

classRenderable

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...

voidsetTextShaderPropertiesOverride (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...

voidsetText (std::string text) noexcept

Updates the text string. More...

std::string_viewtext () 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...

voidwriteUniformValues (helios::rendering::shader::UniformValueMap &uniformValueMap) const noexcept override

Writes uniform values to the given map. More...

voidemit (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

TextRenderPrototype

See Also

TextRenderCommand

See Also

TextMesh

Definition at line 57 of file TextRenderable.ixx.

Public Constructors

TextRenderable()

helios::rendering::text::TextRenderable::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)
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.

89 explicit TextRenderable(
90 std::unique_ptr<helios::rendering::text::TextMesh> textMesh,
91 std::shared_ptr<const helios::rendering::text::TextRenderPrototype> renderPrototype,
92 const std::optional<helios::rendering::text::TextShaderPropertiesOverride>& textShaderPropertiesOverride = std::nullopt
93 ) :
94 textRenderPrototype_(std::move(renderPrototype)),
95 textMesh_(std::move(textMesh)),
97 {
98
100 throw std::invalid_argument("Unexpected nullptr for TextRenderPrototype");
101 }
102
103 }

References textMesh, textMesh_, textRenderPrototype_, textShaderPropertiesOverride and textShaderPropertiesOverride_.

Public Member Functions

emit()

void helios::rendering::text::TextRenderable::emit (helios::rendering::RenderQueue & renderQueue, helios::rendering::shader::UniformValueMap & objectUniformValues, helios::rendering::shader::UniformValueMap & materialUniformValues)
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.

224 void emit(
227 helios::rendering::shader::UniformValueMap& materialUniformValues) const override {
228
229
230 writeUniformValues(materialUniformValues);
231
233 textMesh_.get(),
235 objectUniformValues,
236 materialUniformValues
237 ));
238 };

References helios::rendering::RenderQueue::add, textMesh_, textRenderPrototype_ and writeUniformValues.

localAABB()

const helios::math::aabbf & helios::rendering::text::TextRenderable::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.

130 [[nodiscard]] const helios::math::aabbf& localAABB() const noexcept override {
131 return textMesh_->localAABB(textRenderPrototype_->fontResourceProvider());
132 }

References textMesh_ and textRenderPrototype_.

setText()

void helios::rendering::text::TextRenderable::setText (std::string text)
inline noexcept

Updates the text string.

Parameters
text

The new text to render.

Definition at line 139 of file TextRenderable.ixx.

139 void setText(std::string text) noexcept {
140 textMesh_->setText(std::move(text));
141 }

References text and textMesh_.

setTextShaderPropertiesOverride()

void helios::rendering::text::TextRenderable::setTextShaderPropertiesOverride (helios::rendering::text::TextShaderPropertiesOverride textShaderPropertiesOverride)
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()

std::shared_ptr< const helios::rendering::text::TextRenderPrototype > helios::rendering::text::TextRenderable::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.

162 [[nodiscard]] std::shared_ptr<const helios::rendering::text::TextRenderPrototype> shareTextRenderPrototype() const noexcept {
164 }

Reference textRenderPrototype_.

text()

std::string_view helios::rendering::text::TextRenderable::text ()
inline nodiscard noexcept

Returns the current text string.

Returns

View of the text string.

Definition at line 148 of file TextRenderable.ixx.

148 [[nodiscard]] std::string_view text() const noexcept {
149 return textMesh_->text();
150 }

Reference textMesh_.

Referenced by setText.

textMesh()

const helios::rendering::text::TextMesh & helios::rendering::text::TextRenderable::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.

185 [[nodiscard]] const helios::rendering::text::TextMesh& textMesh() const noexcept {
186 return *textMesh_;
187 }

Reference textMesh_.

Referenced by TextRenderable.

textMesh()

helios::rendering::text::TextMesh & helios::rendering::text::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.

194 [[nodiscard]] helios::rendering::text::TextMesh& textMesh() noexcept {
195 return *textMesh_;
196 }

Reference textMesh_.

textRenderPrototype()

const helios::rendering::text::TextRenderPrototype & helios::rendering::text::TextRenderable::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.

176 }

Reference textRenderPrototype_.

textShaderPropertiesOverride()

std::optional< helios::rendering::text::TextShaderPropertiesOverride > helios::rendering::text::TextRenderable::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.

110 [[nodiscard]] std::optional<helios::rendering::text::TextShaderPropertiesOverride> textShaderPropertiesOverride() noexcept {
112 }

Reference textShaderPropertiesOverride_.

Referenced by setTextShaderPropertiesOverride and TextRenderable.

writeUniformValues()

void helios::rendering::text::TextRenderable::writeUniformValues (helios::rendering::shader::UniformValueMap & uniformValueMap)
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.

206 void writeUniformValues(helios::rendering::shader::UniformValueMap& uniformValueMap) const noexcept override {
207 textRenderPrototype_->textProperties().writeUniformValues(uniformValueMap);
208
210 textShaderPropertiesOverride_->writeUniformValues(uniformValueMap);
211 }
212 }

References textRenderPrototype_ and textShaderPropertiesOverride_.

Referenced by emit.

Protected Member Attributes

textMesh_

std::unique_ptr<helios::rendering::text::TextMesh> helios::rendering::text::TextRenderable::textMesh_
protected

Positioning and styling data (font, position, scale).

Definition at line 75 of file TextRenderable.ixx.

75 std::unique_ptr<helios::rendering::text::TextMesh> textMesh_;

Referenced by emit, localAABB, setText, text, textMesh, textMesh and TextRenderable.

textRenderPrototype_

std::shared_ptr<const helios::rendering::text::TextRenderPrototype> helios::rendering::text::TextRenderable::textRenderPrototype_ = nullptr
protected

Shared prototype containing shader and text properties.

Definition at line 64 of file TextRenderable.ixx.

64 std::shared_ptr<const helios::rendering::text::TextRenderPrototype> textRenderPrototype_ = nullptr;

Referenced by emit, localAABB, shareTextRenderPrototype, TextRenderable, textRenderPrototype and writeUniformValues.

textShaderPropertiesOverride_

std::optional<helios::rendering::text::TextShaderPropertiesOverride> helios::rendering::text::TextRenderable::textShaderPropertiesOverride_
protected

Optional overrides for text shader properties.

Definition at line 70 of file TextRenderable.ixx.

70 std::optional<helios::rendering::text::TextShaderPropertiesOverride> textShaderPropertiesOverride_;

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.