![]() |
Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
|
2D drawable representing a block of rendered text. More...
#include <text_block_2d.hpp>
Inherits rendering_engine::Drawable2D.
Classes | |
| struct | GlyphQuad |
| Renderable quad representing a single glyph. More... | |
| struct | Mesh |
| CPU-side mesh data for glyph quads. More... | |
| struct | Properties |
| struct | ShapedGlyph |
| Result of text shaping for a single glyph. More... | |
Public Member Functions | |
| TextBlock2D (Scene &scene, std::shared_ptr< TextRenderer > textRenderer, Properties properties=Properties()) | |
| Constructs a 2D text block. More... | |
| void | Initialize () override |
| Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names. More... | |
| void | Update (float deltaTime) override |
| Updates logic (animation, movement, etc.) for this drawable. More... | |
| void | Draw (const Camera2D &camera) override |
| Submits this quad to the renderer for drawing. More... | |
| virtual void | SetText (std::string text) |
| Sets the displayed text. More... | |
| void | SetTextColor (glm::vec4 color) |
| Sets the text color. More... | |
| void | SetOutlineColor (glm::vec4 color) |
| Sets the outline color. More... | |
| glm::vec2 | GetDimensions () const |
| Returns text block dimensions. More... | |
| template<> | |
| std::unordered_map< std::string, TextBlock2D::Mesh > | PrepareMeshSlots (const std::vector< std::uint32_t > &glyphs) |
| template<> | |
| std::unordered_map< std::string, TextBlock2D::Mesh > | PrepareMeshSlots (const std::vector< ShapedGlyph > &glyphs) |
Public Member Functions inherited from rendering_engine::Drawable2D | |
| Drawable2D (RenderResourceContext renderContext, Scene &scene) | |
| Constructs the Drawable2D with a resource context. More... | |
| void | Initialize () override |
| Initializes render resources. More... | |
| void | Update (float deltaTime) override |
| Updates model matrix (and any other logic). More... | |
| virtual void | Draw (const Camera2D &camera)=0 |
| Submits this quad to the renderer for drawing. More... | |
| void | SetPosition (const glm::vec2 &position) |
| Sets the quad position in 2D space. More... | |
| void | SetRotation (float angleDegrees) |
| Sets the quad rotation. More... | |
| void | SetScale (const glm::vec2 &scale) |
| Sets the quad scale along each axis. More... | |
| const glm::vec2 & | GetPosition () const |
| Gets the quad position. More... | |
| float | GetRotation () const |
| Gets the quad rotation angle (degrees). More... | |
| const glm::vec2 & | GetScale () const |
| Gets the quad scale. More... | |
| SceneComponent2D & | GetTransform () |
| Access to the underlying SceneComponent2D (transform). More... | |
| const SceneComponent2D & | GetTransform () const |
| void | Destroy () override |
| Requests destruction of this drawable. More... | |
Public Member Functions inherited from rendering_engine::DrawableComponent | |
| DrawableComponent (RenderResourceContext renderContext, Scene &scene) | |
| Constructs the DrawableComponent with a resource context. More... | |
| virtual | ~DrawableComponent ()=default |
| Virtual destructor. More... | |
| virtual void | Initialize () |
| Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names. More... | |
| virtual void | Update (float deltaTime)=0 |
| Updates logic (animation, movement, etc.) for this drawable. More... | |
| virtual void | Shutdown () |
| Releases all render resources owned by this drawable. More... | |
| virtual void | Destroy () |
| Requests destruction of this drawable. More... | |
| void | UpdateOnTick (bool in) |
| DrawableComponent (const DrawableComponent &)=delete | |
| DrawableComponent & | operator= (const DrawableComponent &)=delete |
Protected Member Functions | |
| std::vector< std::uint32_t > | DecodeUtf8 (const std::string &text) |
| Decodes a UTF-8 string into Unicode code points. More... | |
| std::string | CodepointToUtf8 (std::uint32_t codePoint) |
| Converts a Unicode code point to UTF-8. More... | |
| std::vector< ShapedGlyph > | ShapeText (const std::string &text) |
| Shapes text and returns shaped glyphs. More... | |
| void | ConstructMeshAutoLinebreak (const std::vector< std::uint32_t > &codePoints) |
| void | ConstructMesh () |
| Constructs glyph geometry without shaping. More... | |
| void | ShapeTextAndConstructMesh () |
| Shapes text and constructs glyph geometry. More... | |
| GlyphQuad | MakeGlyphQuad (GlyphIndex glyphIndext, float penX, float penY) |
| Creates a glyph quad at the current pen position. More... | |
| void | PushQuad (std::string meshName, std::unordered_map< std::string, TextBlock2D::Mesh > &meshes, GlyphQuad glyphQuad, float horizontalShift=0.0f) |
| Appends a glyph quad to a mesh. More... | |
| void | UploadMeshes (const std::unordered_map< std::string, TextBlock2D::Mesh > &meshes) |
| Uploads prepared meshes to GPU resources. More... | |
| void | SetOutlineThickness (float thicknessPx) |
| Sets outline thickness for all render batches. More... | |
| template<typename T > | |
| std::unordered_map< std::string, TextBlock2D::Mesh > | PrepareMeshSlots (const std::vector< T > &glyphs) |
| Prepares mesh slots based on glyph usage. More... | |
| std::vector< std::string > | SplitString (const std::string &text, std::string separator) |
| Splits a string by a separator. More... | |
| bool | IsTextShapingRequired (std::uint32_t codePoint) const |
| Checks whether shaping is required for a code point. More... | |
Protected Member Functions inherited from rendering_engine::DrawableComponent | |
| void | AddRenderBatch (std::string meshName, std::string materialName) |
Protected Attributes | |
| std::unordered_map< std::string, std::string > | mMaterialMesh |
| const std::shared_ptr< TextRenderer > | mTextRenderer |
| std::shared_ptr< FontResources > | mFontResources |
| glm::vec4 | mColor |
| const std::string | mFontName |
| const unsigned int | mFontSize |
| float | mLineSpacingScale = 1.0f |
| std::string | mText |
| float | mMaxLineLength = 0.0f |
| const TextAlign | mTextAlign |
| glm::vec2 | mDimensions |
| const bool | bIsTextShapeEnabled |
| const float | mOutlineThicknessPx |
Protected Attributes inherited from rendering_engine::Drawable2D | |
| SceneComponent2D | mSceneComponent |
Protected Attributes inherited from rendering_engine::DrawableComponent | |
| RenderResourceContext | mRenderContext |
| Scene & | mScene |
| std::vector< RenderBatch > | mRenderBatches |
| bool | bUpdateOnTick |
Static Protected Attributes | |
| static std::string | sDefaultFontName = "RobotoMono-Regular" |
2D drawable representing a block of rendered text.
Converts UTF-8 text into glyph quads, performs layout and alignment, and submits render batches using font atlas materials.
A TextBlock2D instance is bound to a single font and font size.
Definition at line 52 of file text_block_2d.hpp.
| rendering_engine::TextBlock2D::TextBlock2D | ( | Scene & | scene, |
| std::shared_ptr< TextRenderer > | textRenderer, | ||
| Properties | properties = Properties() |
||
| ) |
Constructs a 2D text block.
| textRenderer | Owning text renderer. |
| properties | Text block configuration. |
Definition at line 41 of file text_block_2d.cpp.
|
protected |
Converts a Unicode code point to UTF-8.
| codePoint | Unicode code point. |
Definition at line 629 of file text_block_2d.cpp.
|
protected |
Constructs glyph geometry without shaping.
Definition at line 325 of file text_block_2d.cpp.
|
protected |
Definition at line 208 of file text_block_2d.cpp.
|
protected |
Decodes a UTF-8 string into Unicode code points.
| text | UTF-8 encoded string. |
Definition at line 138 of file text_block_2d.cpp.
|
overridevirtual |
Submits this quad to the renderer for drawing.
Implements rendering_engine::Drawable2D.
Definition at line 75 of file text_block_2d.cpp.
| glm::vec2 rendering_engine::TextBlock2D::GetDimensions | ( | ) | const |
Returns text block dimensions.
Definition at line 125 of file text_block_2d.cpp.
|
overridevirtual |
Initializes render resource pointers (material, mesh, etc.). Must be called after setting material and mesh names.
Reimplemented from rendering_engine::Drawable2D.
Definition at line 65 of file text_block_2d.cpp.
|
protected |
Checks whether shaping is required for a code point.
| codePoint | Unicode code point. |
Definition at line 614 of file text_block_2d.cpp.
|
protected |
Creates a glyph quad at the current pen position.
| glyphIndex | Glyph identifier. |
| penX | Horizontal pen position. |
| penY | Vertical pen position. |
Definition at line 490 of file text_block_2d.cpp.
| std::unordered_map< std::string, TextBlock2D::Mesh > rendering_engine::TextBlock2D::PrepareMeshSlots | ( | const std::vector< ShapedGlyph > & | glyphs | ) |
Definition at line 724 of file text_block_2d.cpp.
| std::unordered_map< std::string, TextBlock2D::Mesh > rendering_engine::TextBlock2D::PrepareMeshSlots | ( | const std::vector< std::uint32_t > & | glyphs | ) |
Definition at line 693 of file text_block_2d.cpp.
|
protected |
Prepares mesh slots based on glyph usage.
| glyphs | Glyph collection. |
|
protected |
Appends a glyph quad to a mesh.
| meshName | Target mesh name. |
| meshes | Mesh container. |
| glyphQuad | Glyph quad data. |
| horizontalShift | Alignment offset. |
Definition at line 532 of file text_block_2d.cpp.
| void rendering_engine::TextBlock2D::SetOutlineColor | ( | glm::vec4 | color | ) |
Sets the outline color.
| color | RGBA color. |
Definition at line 117 of file text_block_2d.cpp.
|
protected |
Sets outline thickness for all render batches.
| thicknessPx | Thickness in pixels. |
Definition at line 130 of file text_block_2d.cpp.
|
virtual |
Sets the displayed text.
| text | UTF-8 encoded text string. |
Definition at line 88 of file text_block_2d.cpp.
| void rendering_engine::TextBlock2D::SetTextColor | ( | glm::vec4 | color | ) |
Sets the text color.
| color | RGBA color. |
Definition at line 109 of file text_block_2d.cpp.
|
protected |
Shapes text and returns shaped glyphs.
| text | UTF-8 encoded text. |
Definition at line 655 of file text_block_2d.cpp.
|
protected |
Shapes text and constructs glyph geometry.
Definition at line 407 of file text_block_2d.cpp.
|
protected |
Splits a string by a separator.
| text | Input string. |
| separator | Separator string. |
Definition at line 597 of file text_block_2d.cpp.
|
overridevirtual |
Updates logic (animation, movement, etc.) for this drawable.
| deltaTime | Time step (seconds). |
Reimplemented from rendering_engine::Drawable2D.
Definition at line 70 of file text_block_2d.cpp.
|
protected |
Uploads prepared meshes to GPU resources.
| meshes | CPU-side mesh data. |
Definition at line 570 of file text_block_2d.cpp.
|
protected |
Definition at line 272 of file text_block_2d.hpp.
|
protected |
Definition at line 262 of file text_block_2d.hpp.
|
protected |
Definition at line 270 of file text_block_2d.hpp.
|
protected |
Definition at line 264 of file text_block_2d.hpp.
|
protected |
Definition at line 261 of file text_block_2d.hpp.
|
protected |
Definition at line 265 of file text_block_2d.hpp.
|
protected |
Definition at line 266 of file text_block_2d.hpp.
|
protected |
Definition at line 258 of file text_block_2d.hpp.
|
protected |
Definition at line 268 of file text_block_2d.hpp.
|
protected |
Definition at line 274 of file text_block_2d.hpp.
|
protected |
Definition at line 267 of file text_block_2d.hpp.
|
protected |
Definition at line 269 of file text_block_2d.hpp.
|
protected |
Definition at line 260 of file text_block_2d.hpp.
|
staticprotected |
Definition at line 263 of file text_block_2d.hpp.