SDL_VideoModeOK(3)

SDL_VideoModeOK πŸ’–βœ¨

okay bestie, welcome to the SDL API Reference bestie β€” this one's the vibe check for your video modes πŸŽ€


✨ NAME ✨

SDL_VideoModeOK β€” check to see if a particular video mode is supported πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include "SDL.h"

int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);

🌸 DESCRIPTION 🌸

so like, SDL_VideoModeOK is the girl who tells you the truth before you commit, no cap. She returns 0 if the mode you asked for is not supported under any bit depth 😭, OR she returns the bits-per-pixel of the closest available mode with the width, height and requested surface flags you handed her (peep SDL_SetVideoMode for the lore 🫢).

ok but lowkey important: the bits-per-pixel value she gives back is only a suggested mode. That's not the law, that's a suggestion ✨. You can usually request any bpp you want when you're actually setting the video mode, and SDL will emulate that color depth with a shadow video surface. iconic behaviour fr fr πŸ‘‘

also the arguments you pass to SDL_VideoModeOK are literally the same ones you'd pass to SDL_SetVideoMode. same energy, same list, iykyk πŸ’œ


πŸ’… EXAMPLE πŸ’…

SDL_Surface *screen;
Uint32 bpp;
.
.
.
printf("Checking mode 640x480@16bpp.
");
bpp=SDL_VideoModeOK(640, 480, 16, SDL_HWSURFACE);

if(!bpp){
  printf("Mode not available.
");
  exit(-1);
}

printf("SDL Recommends 640x480@%dbpp.
", bpp);
screen=SDL_SetVideoMode(640, 480, bpp, SDL_HWSURFACE);
.
.

πŸŽ€ SEE ALSO πŸŽ€

  • SDL_SetVideoMode
  • SDL_GetVideoInfo

🌈 and that's the whole page bestie, you ate that. go forth and vibe check ur video modes πŸ’–

SDL Β· Tue 11 Sep 2001, 23:01 Β· SDL_VideoModeOK(3) β€” mwah, slay, bye bestie πŸ¦‹πŸ’œβœ¨

πŸ“¦ where this page comes from