|
Flint Engine
Modular C++20 2D game engine powered by SDL3
|
High-level SDL GPU renderer managing pipeline state, batching, and frame presentation. More...
#include <flint/graphics/renderer.h>
Collaboration diagram for Flint::GPURenderer:Public Member Functions | |
| FLINT_API | GPURenderer (IWindow *window, IAssetLoader &assetLoader, ShaderFormat shaderFormat) |
| Construct the renderer and initialize the underlying GPU device for the window. | |
| FLINT_API bool | beginFrame () |
| Acquire the next swapchain texture and prepare the initial GPU command buffer. | |
| FLINT_API void | draw (const std::function< void(RenderQueue &)> &overlayEmit={}) |
| Execute all queued draw commands in layer and submission order. | |
| FLINT_API void | endFrame () |
| Close active render passes, submit the command buffer to the GPU, and present. | |
| FLINT_API void | submit (std::shared_ptr< const Drawable > drawable, DrawLayer layer=DrawLayer::Midground) |
| Queue a shared Drawable for rendering in the current frame. | |
| FLINT_API void | submit (const Drawable *drawable, DrawLayer layer=DrawLayer::Midground) |
| Queue a raw Drawable pointer for rendering in the current frame. | |
| FLINT_API void | setClearColor (Color color) |
| Set the RGBA clear color applied at the start of each frame. | |
| FLINT_API void | setViewport (const SDL_GPUViewport &viewport) |
| Set or override the default rendering viewport. | |
| FLINT_API void | setCamera (const Camera &camera) |
| Update the active camera view transform used for batch coordinate projection. | |
| std::unique_ptr< Shader > | createShader () const |
| Factory method creating a new Shader instance bound to this GPU device. | |
| FLINT_API std::vector< char > | loadShader (const std::string &basePath) const |
| Load raw shader bytecode bytes from the asset loader. | |
| FLINT_API std::string | getShaderPath (const std::string &basePath) const |
| Get the full asset path for a shader base name including system format extension. | |
| ShaderFormat | getShaderFormat () const |
| Get the active GPU shader format. | |
| SDL_GPURenderPass * | getRenderPass () const |
| Return the current frame's active SDL GPU render pass handle. | |
| void | setGPUPresentMode (SDL_GPUPresentMode mode) |
| Configure GPU swapchain presentation mode for the window. | |
| SDL_GPUCommandBuffer * | getCommandBuffer () const |
| Return the current frame's active SDL GPU command buffer handle. | |
| const FloatRect & | getCurrentCameraView () const |
| Return the camera view rectangle used for the current frame projection. | |
| SDL_GPUDevice * | getGPUDevice () const |
| Return the native SDL GPU device owned by this renderer. | |
| IAssetLoader & | getAssetLoader () const |
| Return reference to the core asset loader. | |
| const SDL_GPUViewport & | getDefaultViewport () const |
| Return default full-screen viewport bounds. | |
| FLINT_API SDL_Renderer * | getSDLRenderer () const |
| Return legacy SDL_Renderer handle if running alongside an SDL software fallback pass. | |
| UIPipeline & | getUIPipeline () |
| Return reference to the UI pipeline wrapper. | |
| PrimitivePipeline & | getPrimitivePipeline () |
| Return reference to the primitive point/line pipeline wrapper. | |
| SDL_GPUTexture * | getWhiteTexture () |
| Return shared 1x1 fallback white GPU texture handle. | |
High-level SDL GPU renderer managing pipeline state, batching, and frame presentation.
Owns the SDL GPU device, swapchain lifecycle, and built-in pipeline wrappers (Batch, Primitive, UI).
Standard Frame Execution Lifecycle:
beginFrame() — Acquire swapchain texture and initialize GPU command pass.submit() — Queue drawables sorted by DrawLayer.draw() — Construct RenderQueue, emit draw geometry, drain upload callbacks, and execute batched passes.endFrame() — Close render pass, submit command buffer to GPU, and present. Definition at line 40 of file renderer.h.
|
explicit |
Construct the renderer and initialize the underlying GPU device for the window.
| window | Target window receiving rendered frames. |
| assetLoader | Asset loader used to load built-in shader bytecode. |
| shaderFormat | Active GPU shader format (SPIR-V, MSL, or DXIL). |
| FLINT_API bool Flint::GPURenderer::beginFrame | ( | ) |
|
inlinenodiscard |
Factory method creating a new Shader instance bound to this GPU device.
Definition at line 124 of file renderer.h.
| FLINT_API void Flint::GPURenderer::draw | ( | const std::function< void(RenderQueue &)> & | overlayEmit = {} | ) |
Execute all queued draw commands in layer and submission order.
Performs the multi-stage draw execution:
deferUpload).| FLINT_API void Flint::GPURenderer::endFrame | ( | ) |
Close active render passes, submit the command buffer to the GPU, and present.
Must be called once per frame after draw().
|
inlinenodiscard |
Return reference to the core asset loader.
Definition at line 202 of file renderer.h.
|
inlinenodiscard |
Return the current frame's active SDL GPU command buffer handle.
Definition at line 187 of file renderer.h.
|
inlinenodiscard |
Return the camera view rectangle used for the current frame projection.
Definition at line 192 of file renderer.h.
|
inlinenodiscard |
Return default full-screen viewport bounds.
Definition at line 207 of file renderer.h.
|
inlinenodiscard |
Return the native SDL GPU device owned by this renderer.
Definition at line 197 of file renderer.h.
|
inlinenodiscard |
Return reference to the primitive point/line pipeline wrapper.
Definition at line 221 of file renderer.h.
|
inlinenodiscard |
Return the current frame's active SDL GPU render pass handle.
Definition at line 156 of file renderer.h.
|
inlinenodiscard |
Get the active GPU shader format.
Definition at line 143 of file renderer.h.
|
nodiscard |
Get the full asset path for a shader base name including system format extension.
| basePath | Base shader path. |
|
inlinenodiscard |
Return reference to the UI pipeline wrapper.
Definition at line 216 of file renderer.h.
|
inlinenodiscard |
Return shared 1x1 fallback white GPU texture handle.
Definition at line 226 of file renderer.h.
|
nodiscard |
Load raw shader bytecode bytes from the asset loader.
| basePath | Base path to shader asset without file extension. |
| FLINT_API void Flint::GPURenderer::setCamera | ( | const Camera & | camera | ) |
Update the active camera view transform used for batch coordinate projection.
| camera | Active world camera. |
| FLINT_API void Flint::GPURenderer::setClearColor | ( | Color | color | ) |
Set the RGBA clear color applied at the start of each frame.
| color | Clear color values. |
|
inline |
Configure GPU swapchain presentation mode for the window.
| mode | Desired present mode (VSYNC, IMMEDIATE, or MAILBOX). |
Definition at line 164 of file renderer.h.
| FLINT_API void Flint::GPURenderer::setViewport | ( | const SDL_GPUViewport & | viewport | ) |
Set or override the default rendering viewport.
| viewport | Target GPU viewport bounds. |
| FLINT_API void Flint::GPURenderer::submit | ( | const Drawable * | drawable, |
| DrawLayer | layer = DrawLayer::Midground ) |
Queue a raw Drawable pointer for rendering in the current frame.
| drawable | Non-owning pointer to the drawable. Must remain valid through draw(). |
| layer | Render layer sorting priority; defaults to DrawLayer::Midground. |
| FLINT_API void Flint::GPURenderer::submit | ( | std::shared_ptr< const Drawable > | drawable, |
| DrawLayer | layer = DrawLayer::Midground ) |