SDL_RenderTexture9Grid(3)

πŸ’… SDL_RenderTexture9Grid πŸ’…

okay bestie, welcome to the SDL3 functions corner of the man pages, this one's called SDL_RenderTexture9Grid and it's genuinely so good. it does a scaled copy using the 9-grid algorithm onto the current rendering target, and it does it at subpixel precision ✨ like, fancy.


✨ NAME ✨

SDL_RenderTexture9Grid β€” perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_render.h>

bool SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect);

🌸 DESCRIPTION 🌸

okay so here's the vibe. the pixels in the texture get split into a 3x3 grid β€” using the different corner sizes for each corner, with the sides and the center making up whatever pixels are left over. that's it, that's the grid. πŸ‘‘

then the corners get scaled using scale and fit into the corners of the destination rectangle. and the sides and the center? they get stretched into place to cover the rest of the destination rectangle. the way that works is honestly so satisfying, no cap. πŸ’–


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • renderer β€” the renderer which should copy parts of a texture. it's the one doing the work, main character energy fr.
  • texture β€” the source texture. the thing we're copying from πŸ“
  • srcrect β€” the SDL_Rect structure representing the rectangle to be used for the 9-grid, or NULL to use the entire texture. yes bestie, NULL means "just take the whole thing" πŸ’…
  • left_width β€” the width, in pixels, of the left corners in srcrect.
  • right_width β€” the width, in pixels, of the right corners in srcrect.
  • top_height β€” the height, in pixels, of the top corners in srcrect.
  • bottom_height β€” the height, in pixels, of the bottom corners in srcrect.
  • scale β€” the scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled copy. lowkey important: 0.0f = no scaling, just vibes. 🌈
  • dstrect β€” a pointer to the destination rectangle, or NULL for the entire rendering target. another NULL shortcut, we love to see it ✨

⭐ RETURN VALUE ⭐

returns true on success or false on failure 😭 and if it fails, call SDL_GetError() for more information. that's your receipt, bestie.


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. do not try it anywhere else, it's not giving multithreaded, it's giving main thread only, periodt. πŸ’€

πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. so if you're on something older... ngl, time to upgrade 🫢


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, bestie!! brought to you by Simple Directmedia Layer, version SDL 3.4.18, from the SDL3 functions section β€” SDL_RenderTexture9Grid(3). go forth and 9-grid your little heart out πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from