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

Alpha-blended pipeline for rendering UI elements (text, panels, icons). More...

#include <flint/graphics/pipelines/ui-pipeline.h>

+ Inheritance diagram for Flint::UIPipeline:
+ Collaboration diagram for Flint::UIPipeline:

Public Member Functions

 UIPipeline (const UIPipeline &)=delete
 
UIPipeline & operator= (const UIPipeline &)=delete
 
bool initialize (SDL_GPUDevice *device, ShaderFormat shaderFormat, SDL_GPUTextureFormat swapchainFormat)
 Create the GPU graphics pipeline with alpha blending enabled.
 
void cleanup ()
 Release the pipeline and its shader.
 
- Public Member Functions inherited from Flint::Pipeline
 Pipeline (SDL_GPUDevice *device)
 Construct a pipeline bound to device.
 
virtual bool initialize (Shader *shader, const PipelineConfig &config)
 Create the underlying SDL GPU graphics pipeline.
 
void bind (SDL_GPURenderPass *renderPass)
 Bind this pipeline to the active render pass.
 
SDL_GPUGraphicsPipeline * getPipeline () const
 Return the raw SDL GPU graphics pipeline handle.
 
Shader * getShader () const
 Return the shader associated with this pipeline.
 

Static Public Member Functions

static void setVertexUniforms (SDL_GPUCommandBuffer *commandBuffer, const UIVertexUniforms &uniforms)
 Upload vertex uniforms (screen size and offset) to the vertex stage.
 
static void setFragmentUniforms (SDL_GPUCommandBuffer *commandBuffer, const UIFragmentUniforms &uniforms)
 Upload fragment uniforms (tint color) to the fragment stage.
 
static UIVertexUniforms buildVertexUniforms (float screenWidth, float screenHeight, float offsetX=0.0f, float offsetY=0.0f)
 Build a UIVertexUniforms value.
 
static UIFragmentUniforms buildFragmentUniforms (float r, float g, float b, float a)
 Build a UIFragmentUniforms value.
 

Additional Inherited Members

- Protected Member Functions inherited from Flint::Pipeline
virtual bool configurePipeline (SDL_GPUGraphicsPipelineCreateInfo &pipelineInfo)
 Subclass hook to customize the pipeline create-info before submission.
 
- Protected Attributes inherited from Flint::Pipeline
SDL_GPUDevice * m_device = nullptr
 
SDL_GPUGraphicsPipeline * m_pipeline = nullptr
 
Shader * m_shader = nullptr
 

Detailed Description

Alpha-blended pipeline for rendering UI elements (text, panels, icons).

Vertex buffer layout:

  • location 0: float2 (xy position, in pixels)
  • location 1: float2 (uv texcoord)

Definition at line 36 of file ui-pipeline.h.

Member Function Documentation

◆ buildFragmentUniforms()

static UIFragmentUniforms Flint::UIPipeline::buildFragmentUniforms ( float r,
float g,
float b,
float a )
static

Build a UIFragmentUniforms value.

Parameters
rRed channel in [0, 1].
gGreen channel in [0, 1].
bBlue channel in [0, 1].
aAlpha channel in [0, 1].

◆ buildVertexUniforms()

static UIVertexUniforms Flint::UIPipeline::buildVertexUniforms ( float screenWidth,
float screenHeight,
float offsetX = 0.0f,
float offsetY = 0.0f )
static

Build a UIVertexUniforms value.

Parameters
screenWidthRender-target width in pixels.
screenHeightRender-target height in pixels.
offsetXHorizontal translation offset (default 0).
offsetYVertical translation offset (default 0).

◆ cleanup()

void Flint::UIPipeline::cleanup ( )
virtual

Release the pipeline and its shader.

Reimplemented from Flint::Pipeline.

◆ initialize()

bool Flint::UIPipeline::initialize ( SDL_GPUDevice * device,
ShaderFormat shaderFormat,
SDL_GPUTextureFormat swapchainFormat )

Create the GPU graphics pipeline with alpha blending enabled.

Parameters
deviceSDL GPU device.
shaderFormatBackend shader format (SPIRV, MSL, DXIL).
swapchainFormatColor-target format matching the swap chain.
Returns
true on success.

◆ setFragmentUniforms()

static void Flint::UIPipeline::setFragmentUniforms ( SDL_GPUCommandBuffer * commandBuffer,
const UIFragmentUniforms & uniforms )
static

Upload fragment uniforms (tint color) to the fragment stage.

Parameters
commandBufferActive command buffer.
uniformsData to upload.

◆ setVertexUniforms()

static void Flint::UIPipeline::setVertexUniforms ( SDL_GPUCommandBuffer * commandBuffer,
const UIVertexUniforms & uniforms )
static

Upload vertex uniforms (screen size and offset) to the vertex stage.

Parameters
commandBufferActive command buffer.
uniformsData to upload.

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