Skip to main content

RenderingDevice.ixx File

Low-level rendering device abstraction (OpenGL/Vulkan/etc.). More...

Included Headers

Namespaces Index

namespacehelios
namespacerendering

Graphics rendering infrastructure. More...

Classes Index

classRenderingDevice

Abstract interface for a low-level rendering device. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::rendering::RenderingDevice"

Description

Low-level rendering device abstraction (OpenGL/Vulkan/etc.).

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::rendering::RenderingDevice"

Definition at line 20 of file RenderingDevice.ixx.

20#define HELIOS_LOG_SCOPE "helios::rendering::RenderingDevice"

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file RenderingDevice.ixx
3 * @brief Low-level rendering device abstraction (OpenGL/Vulkan/etc.).
4 */
5module;
6
7#include <memory>
8
9export module helios.rendering.RenderingDevice;
10
11import helios.math.types;
12import helios.util.log;
13import helios.rendering.Renderable;
14import helios.rendering.RenderQueue;
15import helios.rendering.LegacyRenderPass;
16import helios.rendering.text.TextRenderer;
17import helios.rendering.text.FontResourceProvider;
18
19
20#define HELIOS_LOG_SCOPE "helios::rendering::RenderingDevice"
21export namespace helios::rendering {
22
23 /**
24 * @brief Abstract interface for a low-level rendering device.
25 *
26 * This pure virtual class provides the fundamental API for managing
27 * the rendering pipeline and respective contracts for concrete
28 * implementations using a specific rendering backend (e.g., OpenGL, Vulkan).
29 *
30 * ## Responsibilities
31 *
32 * - **Initialization:** Load graphics API function pointers and prepare resources.
33 * - **Render Pass Management:** Begin, execute, and end render passes.
34 * - **Geometry Rendering:** Process `RenderCommand` objects for mesh rendering.
35 * - **Text Rendering:** Provide access to a `TextRenderer` for glyph-based text.
36 *
37 * ## Render Pass Lifecycle
38 *
39 * ```
40 * beginRenderPass(pass) → doRender(pass) → endRenderPass(pass)
41 * ```
42 *
43 * The `render()` convenience method executes all three steps in sequence.
44 *
45 * @see LegacyRenderPass
46 * @see RenderQueue
47 * @see TextRenderer
48 */
50
51 protected:
52 /**
53 * @brief Reflects the initialization state of this device.
54 */
55 bool initialized_ = false;
56
57 /**
58 * @brief The logger used with this RenderingDevice class.
59 *
60 * Defaults to HELIOS_LOG_SCOPE.
61 */
64 );
65
66 public:
67 virtual ~RenderingDevice() = default;
68
69 /**
70 * @brief Initializes this rendering device.
71 *
72 * Should be called when the graphics context was created and before
73 * any rendering operations are performed.
74 *
75 * Implementing classes should load pointers to underlying GL functions
76 * or provide similar API-specific setup.
77 *
78 * @throws std::runtime_error if initialization of the device fails.
79 */
80 virtual void init() = 0;
81
82 /**
83 * @brief Signals this device that the application is now ready to begin a new render pass.
84 *
85 * Implementing classes should prepare the rendering surface at this point and
86 * clear specific buffers.
87 *
88 * This method should be called at the start of each frame before any drawing occurs.
89 *
90 * @param renderPass The LegacyRenderPass that is about to be processed by the rendering device.
91 */
92 virtual void beginRenderPass(helios::rendering::LegacyRenderPass& renderPass) const noexcept = 0;
93
94
95 /**
96 * @brief Advises this RenderingDevice to process the specified LegacyRenderPass.
97 *
98 * A `LegacyRenderPass` consists of `RenderCommand`s this RenderDevice executes, i.e.
99 * binding meshes, materials and shaders as well as drawing geometry.
100 *
101 * @param renderPass A reference to the LegacyRenderPass that holds the `RenderCommand`s to be executed.
102 */
103 virtual void doRender(helios::rendering::LegacyRenderPass& renderPass) const noexcept = 0;
104
105
106 /**
107 * @brief Ends the specified render pass of this RenderingDevice.
108 *
109 * This method should be called when the renderPass was processed by the RenderingDevice,
110 * before the window swaps the buffers.
111 *
112 * Implementing classes should take care of unbinding frame buffers and/or flushing
113 * command buffers.
114 *
115 * @param renderPass The LegacyRenderPass that was processed by the rendering device.
116 */
117 virtual void endRenderPass(helios::rendering::LegacyRenderPass& renderPass) const noexcept = 0;
118
119 /**
120 * @brief Convenience method to subsequently call `beginRenderPass`, `doRender`, and `endRenderPass` (in this order) with the specified `LegacyRenderPass`.
121 *
122 * @param renderPass The LegacyRenderPass to process by this RenderingDevice.
123 */
125 beginRenderPass(renderPass);
126 doRender(renderPass);
127 endRenderPass(renderPass);
128 }
129
130 /**
131 * @brief Returns the text renderer associated with this device.
132 *
133 * Use this to register font families and access text rendering capabilities.
134 *
135 * @return Reference to the `TextRenderer` implementation.
136 *
137 * @see TextRenderer::addFontFamily()
138 */
139 [[nodiscard]] virtual helios::rendering::text::TextRenderer& textRenderer() const noexcept = 0;
140
141 /**
142 * @brief Returns the font resource provider associated with this device.
143 *
144 * Use this to load fonts and access glyph data for text rendering.
145 * Fonts should be loaded before creating `TextRenderPrototype` instances
146 * that reference them.
147 *
148 * @return Reference to the `FontResourceProvider` implementation.
149 *
150 * @see FontResourceProvider::loadFont()
151 */
152 [[nodiscard]] virtual helios::rendering::text::FontResourceProvider& fontResourceProvider() const noexcept = 0;
153
154 /**
155 * @brief Returns the initialized state of this rendering device.
156 *
157 * This method is guaranteed to return `true` if the device was successfully
158 * initialized, otherwise `false`.
159 *
160 * @return `true` if the device was successfully initialized, `false` otherwise.
161 */
162 [[nodiscard]] bool initialized() const noexcept{
163 return initialized_;
164 };
165 };
166
167}
168

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.