OpenGLGlyphTextRenderer Class
Renders and manages text using OpenGL and FreeType. More...
Declaration
Base class
| class | TextRenderer |
|
Abstract interface for text rendering implementations. More... | |
Friends Index
| class | OpenGLDevice |
Public Destructor Index
| ~OpenGLGlyphTextRenderer () override | |
|
Destroys the OpenGLGlyphTextRenderer and releases all OpenGL resources. More... | |
Public Member Functions Index
| void | render (const helios::rendering::text::TextRenderCommand &command, const helios::rendering::shader::UniformValueMap &frameUniformValues) noexcept override |
|
Renders text using the specified render command. More... | |
Private Member Functions Index
| void | init () |
|
Initializes OpenGL resources (VAO and VBO) for text rendering. More... | |
| void | renderText (const std::string_view text, const helios::engine::modules::ui::widgets::types::FontId fontId, std::span< helios::math::vec4f > vertices, helios::rendering::text::FontResourceProvider *fontResourceProvider) noexcept |
|
Renders text at a specified position using a specified font and scale. More... | |
| void | beginRenderPass (helios::rendering::RenderPass &renderPass) const noexcept |
|
Resets cached rendering state at the beginning of a render pass. More... | |
Private Member Attributes Index
| unsigned int | vao_ {} |
|
OpenGL Vertex Array Object for glyph rendering. More... | |
| unsigned int | vbo_ {} |
|
OpenGL Vertex Buffer Object for glyph quad vertices. More... | |
| const helios::ext::opengl::rendering::shader::OpenGLShader * | lastShader_ = nullptr |
|
Cached pointer to the last used shader for state optimization. More... | |
| unsigned int | lastTexture_ = 0 |
|
Cached texture ID for state optimization. More... | |
| unsigned int | lastVao_ = 0 |
|
Cached VAO ID for state optimization. More... | |
Public Static Functions Index
| static int | textTextureUnit () |
|
Returns the texture unit used for text rendering. More... | |
Description
Renders and manages text using OpenGL and FreeType.
This class is responsible for rendering text using cached glyph textures and managing OpenGL resources for efficient rendering. It leverages FreeType to rasterize font glyphs and OpenGL to render them onto the screen. Text rendering is performed by positioning quads (one per character) with texture-mapped glyphs.
The class provides methods for initializing OpenGL resources, loading fonts into a cache, and rendering text at specified positions and scales.
Inherits from the TextRenderer class in the helios rendering system.
Definition at line 55 of file OpenGLGlyphTextRenderer.ixx.
Friends
OpenGLDevice
|
Definition at line 59 of file OpenGLGlyphTextRenderer.ixx.
Reference OpenGLDevice.
Referenced by OpenGLDevice.
Public Destructor
~OpenGLGlyphTextRenderer()
| inline |
Destroys the OpenGLGlyphTextRenderer and releases all OpenGL resources.
Cleans up the Vertex Array Object (VAO), Vertex Buffer Object (VBO), and all cached glyph textures for every loaded font.
Must be called in a valid OpenGL context.
Definition at line 197 of file OpenGLGlyphTextRenderer.ixx.
Public Member Functions
render()
| inline noexcept virtual |
Renders text using the specified render command.
Processes the `TextRenderCommand`, activates the associated shader, applies uniform values, and renders the text string.
- Parameters
-
command The render command containing text and rendering properties.
frameUniformValues Frame-level uniforms (e.g., projection matrix).
Requires a valid OpenGL context and initialized renderer.
Definition at line 234 of file OpenGLGlyphTextRenderer.ixx.
Private Member Functions
beginRenderPass()
| inline noexcept |
Resets cached rendering state at the beginning of a render pass.
This ensures proper shader and VAO binding even when the render queue contents change between frames. Called internally by `OpenGLDevice` before processing the render queue.
- Parameters
-
renderPass The render pass being started (currently unused, reserved for future use).
Definition at line 179 of file OpenGLGlyphTextRenderer.ixx.
init()
| inline |
Initializes OpenGL resources (VAO and VBO) for text rendering.
Creates a vertex array object and vertex buffer for rendering glyph quads. The VBO is configured for dynamic updates (one quad per character).
Must be called before any rendering operations.
Definition at line 69 of file OpenGLGlyphTextRenderer.ixx.
renderText()
| inline noexcept |
Renders text at a specified position using a specified font and scale.
This method uses OpenGL to render text, character by character, by updating vertex buffer objects (VBOs) and binding glyph textures. Each glyph is positioned relative to the given starting position, scaled according to the provided scale factor, and rendered using stored glyph information from a font cache.
- Parameters
-
text The text string to render.
position The starting (x, y) position for the text, in screen space coordinates.
scale The scale factor to apply to the size of each glyph.
fontId The font identifier used to select the font from the font cache.
Definition at line 130 of file OpenGLGlyphTextRenderer.ixx.
Private Member Attributes
lastShader_
| mutable |
Cached pointer to the last used shader for state optimization.
Used to avoid redundant shader program activations. Reset at the beginning of each render pass.
Definition at line 101 of file OpenGLGlyphTextRenderer.ixx.
lastTexture_
| mutable |
Cached texture ID for state optimization.
Used to avoid redundant texture bindings.
Definition at line 108 of file OpenGLGlyphTextRenderer.ixx.
lastVao_
| mutable |
Cached VAO ID for state optimization.
Used to avoid redundant VAO bindings. Reset at the beginning of each render pass.
Definition at line 115 of file OpenGLGlyphTextRenderer.ixx.
vao_
|
OpenGL Vertex Array Object for glyph rendering.
Definition at line 88 of file OpenGLGlyphTextRenderer.ixx.
vbo_
|
OpenGL Vertex Buffer Object for glyph quad vertices.
Definition at line 93 of file OpenGLGlyphTextRenderer.ixx.
Public Static Functions
textTextureUnit()
| inline static |
Returns the texture unit used for text rendering.
- Returns
The texture unit index (always 0).
Definition at line 219 of file OpenGLGlyphTextRenderer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.