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 β€” an SDL_DisplayID, aka the display this mode is associated with. which screen are we talking about? this one tells you. πŸ–₯️
  • format β€” an SDL_PixelFormat, the pixel format. it's giving "how are the pixels arranged bestie".
  • w β€” an int, the width.
  • h β€” an int, the height. (yes, they're a duo, they come as a pair πŸ’•)
  • pixel_density β€” a float, 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 β€” a float, the refresh rate. and heads up: it can be 0.0f for unspecified. not a bug, just vibes being mysterious. πŸ™ˆ
  • refresh_rate_numerator β€” an int, the precise refresh rate numerator. can be 0 for unspecified too.
  • refresh_rate_denominator β€” an int, the precise refresh rate denominator. also 0-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 to SDL_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: those 0.0f and 0 values 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:


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