OpenGLDevice Class
OpenGL implementation of `RenderingDevice`. More...
Declaration
Base class
| class | RenderingDevice |
|
Abstract interface for a low-level rendering device. More... | |
Public Constructors Index
| OpenGLDevice (std::unique_ptr< helios::ext::opengl::rendering::OpenGLMeshRenderer > meshRenderer, std::unique_ptr< helios::ext::opengl::rendering::OpenGLGlyphTextRenderer > textRenderer, std::unique_ptr< helios::rendering::text::FontResourceProvider > fontResourceProvider) | |
|
Constructs an OpenGLDevice with the given renderers and font provider. More... | |
Public Destructor Index
| ~OpenGLDevice () override=default | |
Public Member Functions Index
| void | init () override |
|
Initializes the OpenGL device to access modern OpenGL. More... | |
| void | beginRenderPass (helios::rendering::RenderPass &renderPass) const noexcept override |
|
Begins a new render pass. More... | |
| void | doRender (helios::rendering::RenderPass &renderPass) const noexcept override |
|
Processes render commands and draws geometry and text. More... | |
| void | renderMeshCommands (const helios::rendering::RenderPass &renderPass) const noexcept |
|
Renders all mesh commands in the render pass. More... | |
| void | renderTextCommands (const helios::rendering::RenderPass &renderPass) const noexcept |
|
Renders all text commands in the render pass. More... | |
| void | endRenderPass (helios::rendering::RenderPass &renderPass) const noexcept override |
|
Ends the specified render pass. More... | |
| helios::rendering::text::TextRenderer & | textRenderer () const noexcept |
|
Returns a reference to the text renderer. More... | |
| helios::rendering::text::FontResourceProvider & | fontResourceProvider () const noexcept override |
|
Returns a reference to the font resource provider. More... | |
Private Member Attributes Index
| std::unique_ptr< helios::ext::opengl::rendering::OpenGLGlyphTextRenderer > | textRenderer_ |
|
Text renderer for FreeType-based glyph rendering. More... | |
| std::unique_ptr< helios::ext::opengl::rendering::OpenGLMeshRenderer > | meshRenderer_ |
|
Mesh renderer for geometry rendering. More... | |
| std::unique_ptr< helios::rendering::text::FontResourceProvider > | fontResourceProvider_ |
|
Font resource provider for loading fonts and retrieving glyph data. More... | |
Description
OpenGL implementation of `RenderingDevice`.
`OpenGLDevice` is the concrete OpenGL backend for the helios rendering system. It handles all OpenGL-specific operations including mesh rendering, shader management, and text rendering via `OpenGLGlyphTextRenderer`.
## Responsibilities
- **Initialization:** Load OpenGL function pointers via GLAD.
- **Render Pass Execution:** Configure viewport, clear buffers, and process render commands.
- **Mesh Rendering:** Bind VAOs and issue draw calls for geometry.
- **Text Rendering:** Delegate text commands to `OpenGLGlyphTextRenderer`.
## Usage
```cpp auto textRenderer = std::make_unique<OpenGLGlyphTextRenderer>(); auto device = std::make_unique<OpenGLDevice>(std::move(textRenderer));
// After creating OpenGL context device->init();
// Load fonts via the text renderer device->textRenderer().addFontFamily(FontId{1}, "fonts/arial.ttf"); ```
- See Also
RenderingDevice
- See Also
Definition at line 66 of file OpenGLDevice.ixx.
Public Constructors
OpenGLDevice()
| inline explicit |
Constructs an OpenGLDevice with the given renderers and font provider.
- Parameters
-
meshRenderer The mesh renderer for geometry rendering.
textRenderer The text renderer for glyph-based text rendering.
fontResourceProvider The font resource provider for loading fonts.
Definition at line 95 of file OpenGLDevice.ixx.
References fontResourceProvider and textRenderer.
Public Destructor
~OpenGLDevice()
| default |
Definition at line 86 of file OpenGLDevice.ixx.
Public Member Functions
beginRenderPass()
| inline noexcept virtual |
Begins a new render pass.
This implementation makes sure that the rendering surface is cleared with the current clear color, which can be configured via `clearColor()`.
- Parameters
-
renderPass The render pass to begin.
- See Also
clear()
- See Also
clearColor()
Definition at line 147 of file OpenGLDevice.ixx.
References helios::rendering::Color, helios::rendering::Depth, helios::rendering::RenderTarget::height, helios::rendering::Stencil and helios::rendering::RenderTarget::width.
doRender()
| inline noexcept virtual |
Processes render commands and draws geometry and text.
Iterates through all render commands in the render queue, binds the appropriate shaders and VAOs, applies uniform values, and issues draw calls. After processing geometry, delegates any text render commands to `renderTextCommands()`.
- Parameters
-
renderPass The render pass containing the render queue to be processed.
- See Also
Definition at line 190 of file OpenGLDevice.ixx.
References renderMeshCommands and renderTextCommands.
endRenderPass()
| inline noexcept virtual |
Ends the specified render pass.
The current implementation does nothing.
- Parameters
-
renderPass The render pass to end.
Definition at line 243 of file OpenGLDevice.ixx.
fontResourceProvider()
| inline nodiscard noexcept virtual |
Returns a reference to the font resource provider.
Use this to load fonts before creating `TextRenderPrototype` instances.
- Returns
Reference to the `FontResourceProvider` implementation.
Definition at line 267 of file OpenGLDevice.ixx.
Referenced by OpenGLDevice.
init()
| inline virtual |
Initializes the OpenGL device to access modern OpenGL.
This method must be called **after** the helios application's `setCurrent()` was called for creating a current context. This OpenGL device will then load from this context.
This method uses the `gladLoadGL` method in conjunction with `glfwGetProcAddress`, which returns the address of the specific OpenGL core.
- Todo
-
Provide abstraction for glfwGetProcAddress.
Definition at line 117 of file OpenGLDevice.ixx.
References helios::rendering::RenderingDevice::initialized_ and helios::rendering::RenderingDevice::logger_.
renderMeshCommands()
| inline noexcept |
Renders all mesh commands in the render pass.
Iterates through the mesh render commands in the render queue and delegates each command to the `OpenGLMeshRenderer` for rendering.
- Parameters
-
renderPass The render pass containing mesh render commands.
Definition at line 210 of file OpenGLDevice.ixx.
Referenced by doRender.
renderTextCommands()
| inline noexcept |
Renders all text commands in the render pass.
Iterates through the text render commands in the render queue and delegates each command to the `OpenGLGlyphTextRenderer` for rendering.
- Parameters
-
renderPass The render pass containing text render commands.
Definition at line 228 of file OpenGLDevice.ixx.
Referenced by doRender.
textRenderer()
| inline nodiscard noexcept virtual |
Returns a reference to the text renderer.
Use this to register font families before rendering text.
- Returns
Reference to the `TextRenderer` interface.
- See Also
OpenGLGlyphTextRenderer::addFontFamily()
Definition at line 256 of file OpenGLDevice.ixx.
Referenced by OpenGLDevice.
Private Member Attributes
fontResourceProvider_
|
Font resource provider for loading fonts and retrieving glyph data.
Definition at line 82 of file OpenGLDevice.ixx.
meshRenderer_
|
Mesh renderer for geometry rendering.
Definition at line 77 of file OpenGLDevice.ixx.
textRenderer_
|
Text renderer for FreeType-based glyph rendering.
Definition at line 72 of file OpenGLDevice.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.