SDL_ScaleSurface(3)

πŸ’– SDL_ScaleSurface(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the group chat, where today's main character is SDL_ScaleSurface β€” she makes a brand new surface that's identical to the one you already have, except scaled to the size you want. glow up, but for pixels. ✨


🌸 NAME 🌸

SDL_ScaleSurface β€” creates a new surface identical to the existing surface, scaled to the desired size. literally a copy of your surface but resized, no cap πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_surface.h>

SDL_Surface * SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you hand her a surface and a target size and she hands you back a whole new surface, scaled. iconic.

⚠️ important bestie!! the returned surface should be freed with SDL_DestroySurface(). she is NOT a borrow, she's yours to clean up. don't ghost her, free her. 😭

✨ FUNCTION PARAMETERS ✨

  • surface β€” the surface to duplicate and scale. your OG. the blueprint. 🫢
  • width β€” the width of the new surface. how wide we're going. πŸ“
  • height β€” the height of the new surface. how tall we're going. πŸ“
  • scaleMode β€” the SDL_ScaleMode to be used. pick your scaling vibe. 🌈

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns a copy of the surface, or NULL on failure. and if she fails? call SDL_GetError() for more information β€” she'll tell you what went wrong, fr fr. πŸ’€


🧚 THREAD SAFETY 🧚

This function can be called on different threads with different surfaces. so like, multitask queen energy β€” just keep the surfaces different and you're golden. πŸ”₯


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. vintage-ish but make it fresh. πŸŽ€


🌈 SEE ALSO 🌈


Simple Directmedia Layer made this one, and this page is riding with SDL 3.4.18 β€” mwah, that's the whole manual page for SDL_ScaleSurface(3), drink some water, free your surfaces, and slay the rest of your day πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from