SDL_SetVideoMode(3)
πΈ NAME πΈ
SDL_SetVideoMode β bestie, this is the one that sets up your video mode with the width, height and bits-per-pixel you asked for. (It's from the SDL API Reference manual, section 3, iykyk.)
β¨ SYNOPSIS β¨
#include "SDL.h"
SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
π DESCRIPTION π
Okay so picture this: you wanna set up a video mode, and you've got a width, a height, and a bits-per-pixel, and this function is literally just that. That's the whole assignment. Slay.
Tiny lil plot twist tho: if bpp is 0, it gets treated as the current display bits per pixel. So zero is not "no pixels", it's "whatever we're already on". Periodt.
The flags parameter? Same energy as the flags field of the SDL_Surface structure. You can OR together combinations of these and they're all valid:
π The Flags π
SDL_SWSURFACEβ makes the video surface live in system memory.SDL_HWSURFACEβ makes the video surface live in video memory. Fancy.SDL_ASYNCBLITβ turns on asynchronous updates of the display surface. Ngl this will usually slow down blitting on single CPU machines, but on SMP systems it may give you a speed boost. It's giving "depends on your setup".SDL_ANYFORMATβ so normally, if a video surface with the bits-per-pixel (bpp) you requested isn't available, SDL will emulate one with a shadow surface. PassingSDL_ANYFORMATstops that whole thing and makes SDL use the video surface anyway, regardless of its pixel depth. No shadow, no problem.SDL_HWPALETTEβ gives SDL exclusive palette access. Without this flag you may not always get the colors you request withSDL_SetColorsorSDL_SetPalette. So if your colors are acting up... this is why bestie πSDL_DOUBLEBUFβ enables hardware double buffering, and it's only valid withSDL_HWSURFACE. CallingSDL_Flipwill flip the buffers and update the screen. All your drawing takes place on the surface that isn't being displayed at the moment. If double buffering couldn't be enabled, thenSDL_Flipjust does anSDL_UpdateRecton the entire screen instead. It still works, it's just not the glowy version.SDL_FULLSCREENβ SDL will attempt to use a fullscreen mode. If a hardware resolution change isn't possible (for whatever reason, we don't ask), the next higher resolution gets used and the display window is centered on a black background. Main character fullscreen energy.SDL_OPENGLβ creates an OpenGL rendering context. Heads up: you should have already set your OpenGL video attributes withSDL_GL_SetAttributebeforehand. Do your homework first πSDL_OPENGLBLITβ creates an OpenGL rendering context like the one above, but it also allows normal blitting operations. The screen (2D) surface may have an alpha channel, andSDL_UpdateRectsmust be used for updating changes to the screen surface.SDL_RESIZABLEβ creates a resizable window. When the user resizes it, aSDL_VIDEORESIZEevent gets generated, and you can callSDL_SetVideoModeagain with the new size. Very "go with the flow" of you.SDL_NOFRAMEβ if possible,SDL_NOFRAMEmakes SDL create a window with no title bar and no frame decoration. Fullscreen modes automatically have this flag set, no need to ask.
Note: whatever flagsSDL_SetVideoModecould satisfy get set in theflagsmember of the returned surface. So like, check the receipt, not the request.
Note: thebppparameter is the number of bits per pixel, so abppof24uses the packed representation of 3 bytes/pixel. For the more common 4 bytes/pixel mode, use abppof32. And somewhat oddly β yes we're all side-eyeing it β both15and16will request a 2 bytes/pixel mode, but with different pixel formats. Not me being confused by that the first time π
π RETURN VALUE π
You get the framebuffer surface, or NULL if it fails. That returned surface is freed by SDL_Quit() and should nt be freed by the caller β so hands off, bestie, do not free it yourself π
π₯ SEE ALSO π₯
SDL_LockSurfaceSDL_SetColorsSDL_FlipSDL_Surface
And that's the whole page, fr fr π¦ This was SDL, from the SDL API Reference, dated Tue 11 Sep 2001, 23:01. Go set up that video mode, you've got this πβ¨π
π¦ 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