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 are 0 <= 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 range 0-1, or NULL to ignore this channel. not your fave? just say NULL, she doesn't take it personally. πŸ™ˆ
  • g β€” a pointer that gets filled in with the green channel, normally in the range 0-1, or NULL to ignore this channel.
  • b β€” a pointer that gets filled in with the blue channel, normally in the range 0-1, or NULL to ignore this channel.
  • a β€” a pointer that gets filled in with the alpha channel, normally in the range 0-1, or NULL to 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