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

Owns a pair of SDL GPU shaders (vertex + fragment) tied to one SDL_GPUDevice. More...

#include <flint/graphics/shaders.h>

+ Collaboration diagram for Flint::Shader:

Public Member Functions

 Shader (SDL_GPUDevice *device, ShaderFormat format)
 Construct a Shader bound to device and configured for format binaries.
 
bool loadFromMemory (ShaderStage stage, const void *data, size_t size, Uint32 numSamplers=0, Uint32 numStorageTextures=0, Uint32 numStorageBuffers=0, Uint32 numUniformBuffers=0)
 Compile and upload a shader stage from bytecode already present in memory.
 
SDL_GPUShader * getVertexShader () const
 Return the vertex shader handle tracked by this object (nullptr if absent).
 
SDL_GPUShader * getFragmentShader () const
 Return the fragment shader handle tracked by this object (nullptr if absent).
 
SDL_GPUDevice * getDevice () const
 Return the SDL GPU device that owns these shaders (may be nullptr before init).
 
void cleanup ()
 Release both shader stages, if present, and reset their handles to nullptr.
 

Protected Attributes

SDL_GPUDevice * m_device = nullptr
 
SDL_GPUShader * m_vertexShader = nullptr
 
SDL_GPUShader * m_fragmentShader = nullptr
 
ShaderFormat m_format
 

Detailed Description

Owns a pair of SDL GPU shaders (vertex + fragment) tied to one SDL_GPUDevice.

Shaders are loaded from precompiled bytecode via loadFromMemory() and stay alive until cleanup() or destruction, guaranteeing GPU resources are reclaimed even if only one stage was created.

Definition at line 86 of file shaders.h.


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