SDL_ReadSurfacePixelFloat(3)
π SDL_ReadSurfacePixelFloat π
okay bestie, welcome to SDL_ReadSurfacePixelFloat(3) β yes it's a whole mouthful, and yes it lives in the SDL3 FUNCTIONS corner of the manpage universe. grab a strawberry π and let's get into it.
β¨ NAME β¨
SDL_ReadSurfacePixelFloat β literally just retrieves a single pixel from a surface. one (1) pixel. that's the whole job. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_surface.h>
bool SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a);
β¨ DESCRIPTION β¨
so here's the vibe check on this one: this function prioritizes correctness over speed. she is not racing anybody. she is not optimized. she is simply right every single time. π
which means β and this is the important part, don't skip it β she's suitable for unit tests, but not intended for use in a game engine. do not put her in your render loop, babe. she will not survive the frame budget. π
β¨ FUNCTION PARAMETERS β¨
surfaceβ the surface you're reading from. the whole canvas, the source of truth, the main character. πxβ the horizontal coordinate, and the rules are0 <= x < width. respect the boundary fr fr.yβ the vertical coordinate, and same deal:0 <= y < height. stay in your lane. π¦rβ a pointer that gets filled in with the red channel, normally in the range0-1, orNULLto ignore this channel. not your fave? just sayNULL, she doesn't take it personally. πgβ a pointer that gets filled in with the green channel, normally in the range0-1, orNULLto ignore this channel.bβ a pointer that gets filled in with the blue channel, normally in the range0-1, orNULLto ignore this channel.aβ a pointer that gets filled in with the alpha channel, normally in the range0-1, orNULLto ignore this channel. transparency queen, we love her. β¨
β¨ RETURN VALUE β¨
returns true on success or false on failure β and if it's a false girlie, call SDL_GetError() for more information. she'll tell you what went wrong, she's not mysterious like that. π
β¨ THREAD SAFETY β¨
this function can be called on different threads with different surfaces. different surfaces, bestie β read that twice. she's chill across threads as long as everybody brought their own surface to the party. π«Ά
β¨ AVAILABILITY β¨
available since SDL 3.2.0. iconic behavior, honestly. π
mwah π thanks for reading, go forth and read exactly one pixel at a time β this page came to you from the SDL3 manpage set, Simple Directmedia Layer, version SDL 3.4.18, and yes she's dated the same as SDL_ReadSurfacePixelFloat(3) because that's just how these pages roll. bye bestie! πβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms