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

◆ loadFromMemory()

bool Flint::GPUTexture::loadFromMemory ( SDL_GPUDevice * device,
const void * data,
size_t size )
inline

Upload an image from memory to the GPU.

Decodes the image with SDL_image and converts it to RGBA32 if it isn't already, so any source format (RGB, palettized, greyscale, etc.) uploads correctly. Allocates a 2-D R8G8B8A8_UNORM texture, copies the pixels row by row into a transfer buffer (handling source row padding), uploads, and creates a nearest-neighbor clamp-to-edge sampler.

Parameters
deviceSDL GPU device to use for resource creation.
dataPointer to raw image file bytes (e.g. PNG, BMP, etc.).
sizeNumber of bytes in data.
Returns
true on success, false if any GPU operation fails.

Definition at line 78 of file gpu-texture.h.