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β theSDL_Rectstructure representing the rectangle to be used for the 9-grid, orNULLto use the entire texture. yes bestie,NULLmeans "just take the whole thing" πleft_widthβ the width, in pixels, of the left corners insrcrect.right_widthβ the width, in pixels, of the right corners insrcrect.top_heightβ the height, in pixels, of the top corners insrcrect.bottom_heightβ the height, in pixels, of the bottom corners insrcrect.scaleβ the scale used to transform the corner ofsrcrectinto the corner ofdstrect, or0.0ffor an unscaled copy. lowkey important:0.0f= no scaling, just vibes. πdstrectβ a pointer to the destination rectangle, orNULLfor the entire rendering target. anotherNULLshortcut, 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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms