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

Dynamic 2D batching engine processing shape vector geometry and hardware-accelerated text strings. *UICanvas acts as the graphics compositor for the UI layer. It intercepts layout draw commands, pools transient vertex lists into unified buffers to optimize pipeline state swaps, and coordinates a sliding frame cache system that automatically tracks and flushes unreferenced font textures from VRAM. More...

#include <flint/ui/ui-canvas.h>

+ Collaboration diagram for Flint::UICanvas:

Public Member Functions

FLINT_API UICanvas (GPURenderer &renderer)
 Binds the UI renderer subsystem to the master application graphics context layout tree.
 
 UICanvas (const UICanvas &)=delete
 
UICanvas & operator= (const UICanvas &)=delete
 
FLINT_API void emit (RenderQueue &queue)
 
FLINT_API void uploadGeometry (SDL_GPUCommandBuffer *cmd)
 Pass 1 of the render loop: Synchronizes local vertex lists down to the physical GPU VRAM.
 
FLINT_API void flushDrawCalls (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *commandBuffer)
 Pass 2 of the render loop: Binds graphics pipelines and triggers draw execution commands.
 
FLINT_API void setScreenSize (Vec2f size)
 Syncs internal display bounding metrics to transform absolute screen pixel bounds cleanly.
 
FLINT_API void drawRect (Rect< float > rect, Color color)
 Submits a flat quad drawing sequence down to the current active runtime pipeline layer.
 
FLINT_API void drawText (std::string text, float x, float y, float fontSize, Color color, std::string fontName="", uint16_t weight=400)
 Enqueues a string draw command record to be processed during the geometry generation pass.
 
FLINT_API void drawTexture (const GPUTexture &texture, Rect< float > rect, Color tint={255, 255, 255, 255})
 Appends a geometric quad textured draw record down to the dynamic vertex batch structure arrays.
 
Vec2f getScreenSize () const
 Returns the active window coordinates representing the screen boundaries.
 
FLINT_API Vec2f measureText (const std::string &text, float fontSize, const std::string &fontName="", uint16_t weight=400)
 Calculates structural spatial dimensions a text block requires before executing layout renders.
 
FLINT_API float getGlyphCenterOffset (const std::string &text, float fontSize, const std::string &fontName="", uint16_t weight=400)
 
FLINT_API bool loadFont (std::vector< char > &&data, const std::string &fontName, uint16_t weight=400)
 Registers raw binary TTF font file data into the subsystem memory allocator.
 
void setDefaultFont (const std::string &name)
 Assigns the base default fallback typography name token.
 
FLINT_API void discardDrawCalls ()
 Instantly clears local staging arrays, abandoning all un-flushed vector and character draw steps.
 

Detailed Description

Dynamic 2D batching engine processing shape vector geometry and hardware-accelerated text strings. *UICanvas acts as the graphics compositor for the UI layer. It intercepts layout draw commands, pools transient vertex lists into unified buffers to optimize pipeline state swaps, and coordinates a sliding frame cache system that automatically tracks and flushes unreferenced font textures from VRAM.

Definition at line 107 of file ui-canvas.h.

Member Function Documentation

◆ drawRect()

FLINT_API void Flint::UICanvas::drawRect ( Rect< float > rect,
Color color )

Submits a flat quad drawing sequence down to the current active runtime pipeline layer.

Parameters
rectCalculated screen space dimension coordinate box tracking the destination boundary.
colorThe target uniform tint vector applied to the shape primitive.

◆ drawText()

FLINT_API void Flint::UICanvas::drawText ( std::string text,
float x,
float y,
float fontSize,
Color color,
std::string fontName = "",
uint16_t weight = 400 )

Enqueues a string draw command record to be processed during the geometry generation pass.

Note
The string text layout is processed out of an optimized instance lookup map to prevent redundant generation passes.

◆ drawTexture()

FLINT_API void Flint::UICanvas::drawTexture ( const GPUTexture & texture,
Rect< float > rect,
Color tint = {255, 255, 255, 255} )

Appends a geometric quad textured draw record down to the dynamic vertex batch structure arrays.

Parameters
textureReference mapping straight to the target asset allocation buffer container.
rectFinal spatial destination pixel bounds on the display grid canvas.
tintGlobal multiplicative color modifier channel adjustments.

◆ flushDrawCalls()

FLINT_API void Flint::UICanvas::flushDrawCalls ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * commandBuffer )

Pass 2 of the render loop: Binds graphics pipelines and triggers draw execution commands.

Warning
Must execute within an open active render pass window. Unreferenced text strings are automatically calculated and erased from VRAM at the conclusion of this pass step.

◆ getScreenSize()

Vec2f Flint::UICanvas::getScreenSize ( ) const
inline

Returns the active window coordinates representing the screen boundaries.

Definition at line 169 of file ui-canvas.h.

◆ loadFont()

FLINT_API bool Flint::UICanvas::loadFont ( std::vector< char > && data,
const std::string & fontName,
uint16_t weight = 400 )

Registers raw binary TTF font file data into the subsystem memory allocator.

Parameters
dataBinary stream buffer moving the contents of the file.
fontNameExplicit identification key assigned to track this family grouping.
weightSpecific fallback prioritization code mapped to identify the variant typeface weight.

◆ measureText()

FLINT_API Vec2f Flint::UICanvas::measureText ( const std::string & text,
float fontSize,
const std::string & fontName = "",
uint16_t weight = 400 )

Calculates structural spatial dimensions a text block requires before executing layout renders.

Note
Frequently polled by UINode::measure blocks to evaluate dynamic layout budgeting flows.
Returns
A dimensions vector tracking absolute horizontal and vertical pixel bounds.

◆ setDefaultFont()

void Flint::UICanvas::setDefaultFont ( const std::string & name)
inline

Assigns the base default fallback typography name token.

Definition at line 197 of file ui-canvas.h.

◆ uploadGeometry()

FLINT_API void Flint::UICanvas::uploadGeometry ( SDL_GPUCommandBuffer * cmd)

Pass 1 of the render loop: Synchronizes local vertex lists down to the physical GPU VRAM.

Note
Must be called strictly during an open copy command pass before any execution commands are submitted. Maps memory ranges and transfers shape allocations alongside generating new rasterized GpuTextItems.

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