SDL_CreateSurface(3)
β¨ SDL_CreateSurface β it's giving brand new surface π
okay bestie, this one lives in the SDL3 FUNCTIONS section of the manual, so you already know it's a glow-up moment. It's SDL_CreateSurface(3), and it's here to hand you a shiny fresh surface with exactly the pixel format you asked for. π¦
πΈ NAME πΈ
SDL_CreateSurface β Allocate a new surface with a specific pixel format.
π SYNOPSIS π
#include <SDL3/SDL_surface.h>
SDL_Surface * SDL_CreateSurface(int width, int height, SDL_PixelFormat format);
π DESCRIPTION π
So here's the tea: the pixels of the new surface are initialized to zero. That's it, that's the whole vibe β clean slate, all zeroes, no drama. β¨
π FUNCTION PARAMETERS π
widthβ the width of the surface. like, how wide bestie.heightβ the height of the surface. the vertical situation.formatβ theSDL_PixelFormatfor the new surface's pixel format. this is the whole lewk, don't skip it. π
π«Ά RETURN VALUE π«Ά
Returns the new SDL_Surface structure that is created β slay β or NULL on failure. π If you get NULL, do not panic, just call SDL_GetError() for more information and it'll tell you what went wrong.
ngl a NULL here is a whole mood ruiner, so always check fr fr.
π§ THREAD SAFETY π§
It is safe to call this function from any thread. periodt. every thread can get one, no gatekeeping. π
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on anything olderβ¦ it's not giving, sorry bestie. π
π SEE ALSO π
iykyk: you made it, so eventually you gotta SDL_DestroySurface it. don't leave your surfaces orphaned, that's not main character energy. πΈ
okay that's the whole page!! ππ this was Simple Directmedia Layer business, brought to you by SDL 3.4.18 β yes, that's the version, and the docs date along with it. go make something iconic with your zeroed-out little surface, bestie. ππ¦β¨
π¦ 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