SDL_GetPointerProperty(3)

✨ SDL_GetPointerProperty(3) ✨

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetPointerProperty πŸ’… she's a little function that goes digging through a pile of properties and pulls out a pointer for you. no cap.


🌸 NAME 🌸

SDL_GetPointerProperty β€” get a pointer property out of a whole group of properties. yes, a group. she's not picking one lonely property, she's scanning the whole friend group 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_properties.h>

void * SDL_GetPointerProperty(SDL_PropertiesID props, const char *name, void *default_value);

look at her. iconic. three args, one pointer, zero drama ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so, by convention (and conventions are just ~vibes with consequences~), the names of properties that SDL exposes on objects start with "SDL." β€” like, that's the public-facing aesthetic, that's the main character energy πŸ‘‘

and the properties SDL uses internally start with "SDL.internal." β€” those ones are the backstage crew, the stagehands, the ones you do NOT talk to πŸ™ˆ

both of those groups should be considered read-only and should not be modified by applications. fr fr. hands off, bestie. don't touch the internals. that's not your business, that's not my business, that's nobody's business πŸ’€


πŸ’– FUNCTION PARAMETERS πŸ’–

  • props β€” the properties to query. this is the group chat you're scrolling through πŸ”
  • name β€” the name of the property you're looking for. this is the @ mention, the name tag, the "hey you" 🌈
  • default_value β€” the default value of the property. this is the outfit she wears if she can't find anything better. the fallback fit πŸŽ€

⭐ RETURN VALUE ⭐

she returns the value of the property 🫢

OR, if it is not set, or it's not a pointer property, she hands you back default_value instead. no crumbs, no drama, just the backup plan πŸ’…


πŸ”₯ THREAD SAFETY πŸ”₯

okay so it is safe to call this function from any thread 🌈 β€” go off, queen, multithread away.

BUT. (there's always a but, isn't there 😭) the data returned is not protected, and it could potentially be freed if you call SDL_SetPointerProperty() or SDL_ClearProperty() on these properties from another thread. like, she handed you the pointer and somebody else yanked the rug. πŸ’€

if you need to avoid this, use SDL_LockProperties() and SDL_UnlockProperties(). lock it down, babe πŸ”’

πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL 3.2.0. she's not new-new, but she's not ancient either. a queen in her prime ✨


🧚 SEE ALSO 🧚

the whole squad 🫢 go read them too, iykyk πŸ’–


and that's the tea, bestie πŸ“ this has been brought to you by Simple Directmedia Layer, version SDL 3.4.18 (no date on the tin, but honestly? timeless πŸ‘‘). stay hydrated, lock your properties, and don't modify the "SDL.internal." ones. periodt πŸ’…βœ¨

πŸ“¦ where this page comes from