|
Size: 1209
Comment: cmpmodes in SDL_video.c shows the sort order is different.
|
Size: 1766
Comment: Simple example printing some mode info of display index 0 and mode index 0.
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 26: | Line 26: |
| You can add your code example here | int display_count = 0, display_index = 0, mode_index = 0; SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 }; if ((display_count = SDL_GetNumVideoDisplays()) < 1) { SDL_Log("SDL_GetNumVideoDisplays returned: %i", display_count); return 1; } if (SDL_GetDisplayMode(display_index, mode_index, &mode) != 0) { SDL_Log("SDL_GetDisplayMode failed: %s", SDL_GetError()); exit(EXIT_FAILURE); } SDL_Log("SDL_GetDisplayMode(0, 0, &mode):\t\t%i bpp\t%i x %i", SDL_BITSPERPIXEL(mode.format), mode.w, mode.h); |
SDL_GetDisplayMode
Use this function to get information about a specific display mode.
Contents
Syntax
int SDL_GetDisplayMode(int displayIndex,
int modeIndex,
SDL_DisplayMode* mode)
Function Parameters
displayIndex |
the index of the display to query |
modeIndex |
the index of the display mode to query |
mode |
an SDL_DisplayMode structure filled in with the mode at modeIndex |
Return Value
Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.
Code Examples
int display_count = 0, display_index = 0, mode_index = 0;
SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
if ((display_count = SDL_GetNumVideoDisplays()) < 1) {
SDL_Log("SDL_GetNumVideoDisplays returned: %i", display_count);
return 1;
}
if (SDL_GetDisplayMode(display_index, mode_index, &mode) != 0) {
SDL_Log("SDL_GetDisplayMode failed: %s", SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_Log("SDL_GetDisplayMode(0, 0, &mode):\t\t%i bpp\t%i x %i", SDL_BITSPERPIXEL(mode.format), mode.w, mode.h);
Remarks
The display modes are sorted in this priority:
width -> largest to smallest
height -> largest to smallest
bits per pixel -> more colors to fewer colors
packed pixel layout -> largest to smallest
refresh rate -> highest to lowest
