|
Size: 1709
Comment: Code example
|
Size: 1742
Comment: Added GetNumVideoDisplays to related functions, since video display index is required
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 63: | Line 63: |
| .[[SDL_SDL_GetNumVideoDisplays]] |
SDL_GetCurrentDisplayMode
Use this function to get information about the current display mode.
Contents
Syntax
int SDL_GetCurrentDisplayMode(int displayIndex,
SDL_DisplayMode* mode)
Function Parameters
displayIndex |
the index of the display to query |
mode |
an SDL_DisplayMode structure filled in with the current display mode |
Return Value
Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.
Code Examples
// Using SDL2's SDL_GetCurrentDisplayMode()
#include <SDL2/SDL.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]){
SDL_Init(SDL_INIT_VIDEO);
// Declare display mode structure to be filled in.
SDL_DisplayMode current;
// Get current display mode of primary display (0).
int should_be_zero = SDL_GetCurrentDisplayMode(0, ¤t);
if(should_be_zero != 0)
// In case of error...
cout << "Could not get current display mode: " << SDL_GetError();
else
// On success, print the current display mode.
cout << "Current display mode is " << current.w << 'x' << current.h << "px @ " << current.refresh_rate << "hz. \n";
// Clean up and exit the program.
SDL_Quit();
return 0;
}
Remarks
You can add useful comments here
