Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
ui-pipeline.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include "flint/graphics/pipelines/pipeline-base.h"
5
6#include <SDL3/SDL_gpu.h>
7
8namespace Flint {
16 float screenSize[2];
17 float offset[2];
18 };
19
26 float color[4];
27 };
28
36 class UIPipeline : public Pipeline {
37 public:
38 UIPipeline() = default;
39
40 virtual ~UIPipeline() override = default;
41
42 UIPipeline(const UIPipeline &) = delete;
43 UIPipeline &operator=(const UIPipeline &) = delete;
44
53 bool initialize(SDL_GPUDevice *device, ShaderFormat shaderFormat,
54 SDL_GPUTextureFormat swapchainFormat);
55
62 static void setVertexUniforms(SDL_GPUCommandBuffer *commandBuffer,
63 const UIVertexUniforms &uniforms);
64
71 static void setFragmentUniforms(SDL_GPUCommandBuffer *commandBuffer,
72 const UIFragmentUniforms &uniforms);
73
82 static UIVertexUniforms buildVertexUniforms(float screenWidth, float screenHeight,
83 float offsetX = 0.0f, float offsetY = 0.0f);
84
93 static UIFragmentUniforms buildFragmentUniforms(float r, float g, float b, float a);
94
98 void cleanup();
99
100 private:
101 using inherited = Pipeline;
102 std::unique_ptr<Shader> m_shader;
103 };
104}
Base class for GPU graphics pipelines.
static UIFragmentUniforms buildFragmentUniforms(float r, float g, float b, float a)
Build a UIFragmentUniforms value.
static void setFragmentUniforms(SDL_GPUCommandBuffer *commandBuffer, const UIFragmentUniforms &uniforms)
Upload fragment uniforms (tint color) to the fragment stage.
void cleanup()
Release the pipeline and its shader.
static UIVertexUniforms buildVertexUniforms(float screenWidth, float screenHeight, float offsetX=0.0f, float offsetY=0.0f)
Build a UIVertexUniforms value.
bool initialize(SDL_GPUDevice *device, ShaderFormat shaderFormat, SDL_GPUTextureFormat swapchainFormat)
Create the GPU graphics pipeline with alpha blending enabled.
static void setVertexUniforms(SDL_GPUCommandBuffer *commandBuffer, const UIVertexUniforms &uniforms)
Upload vertex uniforms (screen size and offset) to the vertex stage.
Alpha-blended pipeline for rendering UI elements (text, panels, icons).
Definition ui-pipeline.h:36
Fragment uniforms for the UI pipeline.
Definition ui-pipeline.h:25
Vertex uniforms for the UI pipeline.
Definition ui-pipeline.h:15