SDL_SetTextureScaleMode(3)

πŸ’… SDL_SetTextureScaleMode(3) β€” SDL3 FUNCTIONS πŸ’…

okay bestie, so this one lives in the SDL3 function family (you'll see it hanging out with its siblings in SDL3 FUNCTIONS), and it's literally the glow-up button for how your textures get scaled. let's get into it ✨


✨ NAME ✨

SDL_SetTextureScaleMode β€” set the scale mode used for texture scale operations. that's it, that's the whole job description πŸŽ€


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_render.h>

bool SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);

two args, one bool, so simple it's giving minimalism πŸ’œ


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first thing you need to know: the default texture scale mode is SDL_SCALEMODE_LINEAR. that's the vibe you get if you never touch this function. it's the factory setting, the no-thoughts-just-vibes default 🌈

and here's the tea 🍡 β€” if the scale mode you ask for isn't supported, SDL doesn't just fail on you. it picks the closest supported mode instead. so like, you get something, just maybe not the exact thing you ordered. lowkey thoughtful ngl 🫢


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • texture β€” the texture to update. this is the lil guy you're about to change up πŸ’–
  • scaleMode β€” the SDL_ScaleMode to use for texture scaling. this is the fit you're picking out for it πŸ‘‘

⭐ RETURN VALUE ⭐

Returns true on success or false on failure β€” and if it's a false kinda day, call SDL_GetError() for more information. she will tell you what went wrong, she's not mysterious about it πŸ’…


πŸ”₯ THREAD SAFETY πŸ”₯

bestie. listen. this function should only be called on the main thread. no side quests, no background threads, no "but it worked that one time". main thread only, periodt πŸ’€

πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. so if you're on something older, it's not ghosting you β€” it genuinely wasn't born yet πŸ™ˆ


🌈 SEE ALSO 🌈


and that's the whole page, bestie β€” go forth and scale your textures with taste πŸ’œβœ¨

signed off with love by the Simple Directmedia Layer girlies β€” this is from SDL 3.4.18 documentation, and yes the page header said SDL_SetTextureScaleMode(3) twice, we love a consistent queen πŸŽ€

πŸ“¦ where this page comes from