Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::GPURenderer Class Reference

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

 GPURenderer (IWindow *window, IAssetLoader &assetLoader, ShaderFormat shaderFormat)
 Construct the renderer and initialize the underlying GPU device for the window.
 
bool beginFrame ()
 Acquire the next swapchain texture and prepare the initial GPU command buffer.
 
void draw (const std::function< void(RenderQueue &)> &overlayEmit={})
 Execute all queued draw commands in layer and submission order.
 
void endFrame ()
 Close active render passes, submit the command buffer to the GPU, and present.
 
void submit (std::shared_ptr< const Drawable > drawable, DrawLayer layer=DrawLayer::Midground)
 Queue a shared Drawable for rendering in the current frame.
 
void submit (const Drawable *drawable, DrawLayer layer=DrawLayer::Midground)
 Queue a raw Drawable pointer for rendering in the current frame.
 
void setClearColor (Color color)
 Set the RGBA clear color applied at the start of each frame.
 
void setViewport (const SDL_GPUViewport &viewport)
 Set or override the default rendering viewport.
 
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.
 
std::vector< char > loadShader (const std::string &basePath) const
 Load raw shader bytecode bytes from the asset loader.
 
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.
 
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.
 

Detailed Description

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:

  1. beginFrame() — Acquire swapchain texture and initialize GPU command pass.
  2. submit() — Queue drawables sorted by DrawLayer.
  3. draw() — Construct RenderQueue, emit draw geometry, drain upload callbacks, and execute batched passes.
  4. endFrame() — Close render pass, submit command buffer to GPU, and present.

Definition at line 39 of file renderer.h.


The documentation for this class was generated from the following file: