SDL_DisplayMode(3type)
β¨ SDL_DisplayMode β¨
okay bestie, welcome to the SDL_DisplayMode page from the SDL3 DATATYPES chapter of the manual π this one is a 3type page, meaning it's all about a type, not a function β and it's literally the structure that defines a display mode. the whole vibe of "what shape is my screen and how fast does it go" lives in here.
πΈ NAME πΈ
SDL_DisplayMode β the structure that defines a display mode. no cap, that's the whole job description. π
π SYNOPSIS π
first things first, you gotta pull in the header:
#include <SDL3/SDL_video.h>
and here's the struct in all its glory, every single field, verbatim, don't you dare skip one:
typedef struct SDL_DisplayMode
{
SDL_DisplayID displayID; /**< the display this mode is associated with */
SDL_PixelFormat format; /**< pixel format */
int w; /**< width */
int h; /**< height */
float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */
int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */
int refresh_rate_denominator; /**< precise refresh rate denominator */
SDL_DisplayModeData *internal; /**< Private */
} SDL_DisplayMode;
let me walk you through the cast of characters, because every field is kind of a main character here π
displayIDβ anSDL_DisplayID, aka the display this mode is associated with. which screen are we talking about? this one tells you. π₯οΈformatβ anSDL_PixelFormat, the pixel format. it's giving "how are the pixels arranged bestie".wβ anint, the width.hβ anint, the height. (yes, they're a duo, they come as a pair π)pixel_densityβ afloat, the scale converting size to pixels. the docs give the iconic example: a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels. math ate, honestly. π₯refresh_rateβ afloat, the refresh rate. and heads up: it can be0.0ffor unspecified. not a bug, just vibes being mysterious. πrefresh_rate_numeratorβ anint, the precise refresh rate numerator. can be0for unspecified too.refresh_rate_denominatorβ anint, the precise refresh rate denominator. also0-able when it's unspecified. the numerator and denominator are the precise little duo that does the exact fraction thing when the float isn't enough. π§internalβ a pointer toSDL_DisplayModeData, and the comment says it all: Private. do NOT touch it. it's not yours, it's not mine, it's the library's. hands off, bestie. π
lowkey important: those0.0fand0values for refresh rate mean unspecified, not "your monitor runs at zero hertz". don't panic. π«Ά
π AVAILABILITY π
this struct is available since SDL 3.2.0. so if you're on anything older, sorry babe, no SDL_DisplayMode for you. π
π¦ SEE ALSO π¦
go read these next, they're all in the group chat:
SDL_GetFullscreenDisplayModes(3)SDL_GetDesktopDisplayMode(3)SDL_GetCurrentDisplayMode(3)SDL_SetWindowFullscreenMode(3)SDL_GetWindowFullscreenMode(3)
and that's the page, bestie, you understood the assignment π this was brought to you by Simple Directmedia Layer, SDL version 3.4.18, and the SDL_DisplayMode(3type) era. go forth and slay your display modes β¨π
π¦ 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