SDL_Surface(3)
๐ SDL_Surface(3) ๐
okay so bestie, you've stumbled into the SDL API Reference and this is the page about surfaces โ the single most important lil struct in all of SDL graphics. buckle up, hydrate, and let's go ๐ธ
โจ NAME โจ
SDL_Surface โ Graphical Surface Structure ๐จ
๐ STRUCTURE DEFINITION ๐
here's the whole vibe, laid out exactly how it lives in the header, no cap:
typedef struct SDL_Surface {
Uint32 flags; /* Read-only */
SDL_PixelFormat *format; /* Read-only */
int w, h; /* Read-only */
Uint16 pitch; /* Read-only */
void *pixels; /* Read-write */
/* clipping information */
SDL_Rect clip_rect; /* Read-only */
/* Reference count -- used when freeing surface */
int refcount; /* Read-mostly */
/* This structure also contains private fields not shown here */
} SDL_Surface;
๐ notice the comments on each field, they tell you what you're allowed to touch. read them. respect them.
๐ฆ STRUCTURE DATA ๐ฆ
flagsโ the surface flags, aka the whole personality of your surface ๐ฉformatโ the pixel formatw,hโ width and height of the surface ๐pitchโ length of a surface scanline, in bytespixelsโ pointer to the actual pixel data, the real MVP ๐clip_rectโ the surface clip rectangle โ๏ธ
๐ DESCRIPTION ๐
SDL_Surface's represent areas of "graphical" memory โ memory that can be drawn to. that's literally the whole point of them, they're canvases you can paint on ๐
the video framebuffer is returned as a SDL_Surface by SDL_SetVideoMode and SDL_GetVideoSurface. so yes, your whole screen is lowkey just a surface. main character energy fr.
most of the fields should be pretty obvious. w and h are the width and height of the surface in pixels. pixels is a pointer to the actual pixel data, and โ listen โ the surface should be locked before accessing this field. do not skip that step, i'm begging ๐ซ
the clip_rect field is the clipping rectangle as set by SDL_SetClipRect.
๐ the flags field ๐
the following are supported in the flags field. there's a lot of them, and each one is a whole mood:
SDL_SWSURFACEโ surface is stored in system memory ๐งSDL_HWSURFACEโ surface is stored in video memory ๐ฎSDL_ASYNCBLITโ surface uses asynchronous blits if possible โกSDL_ANYFORMATโ allows any pixel-format (Display surface) ๐SDL_HWPALETTEโ surface has exclusive palette ๐จSDL_DOUBLEBUFโ surface is double buffered (Display surface) ๐ชSDL_FULLSCREENโ surface is full screen (Display Surface) ๐ฅ๏ธSDL_OPENGLโ surface has an OpenGL context (Display Surface) ๐บSDL_OPENGLBLITโ surface supports OpenGL blitting (Display Surface) โจSDL_RESIZABLEโ surface is resizable (Display Surface) โ๏ธSDL_HWACCELโ surface blit uses hardware acceleration ๐๏ธSDL_SRCCOLORKEYโ surface use colorkey blitting ๐SDL_RLEACCELโ colorkey blitting is accelerated with RLE ๐จSDL_SRCALPHAโ surface blit uses alpha blending ๐ซฅSDL_PREALLOCโ surface uses preallocated memory ๐ฆ
several of these are tagged (Display surface) or (Display Surface) โ that's not decoration, that's telling you they only apply to the display surface, iykyk ๐
๐ SEE ALSO ๐
SDL_PixelFormat
and that's the page, bestie!! you ate that ๐
this was the SDL_Surface(3) page from the SDL API Reference, dated Tue 11 Sep 2001, 23:01 โ yes, an absolute icon from an absolute era, we stan a vintage queen ๐๐ซถ mwah, go lock your surface before you touch pixels, love u bye ๐๐โจ
๐ฆ where this page comes from
- debian bookworm: libsdl1.2-dev 1.2.15+dfsg2-8 ยท LGPL-2.1-or-later
- nixos 26.05: SDL_sixel 0-unstable-2016-02-06
- nixpkgs unstable: SDL_sixel 0-unstable-2016-02-06
- ubuntu jammy: libsdl1.2-dev 1.2.15+dfsg2-6 ยท LGPL-2.1-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms