Wiki Page Content

Differences between revisions 14 and 15
Revision 14 as of 2012-05-27 02:41:01
Size: 1709
Editor: ChrisBush
Comment: Code example
Revision 15 as of 2012-05-27 02:44:28
Size: 1742
Editor: ChrisBush
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.

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, &current);
  
  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


CategoryAPI, CategoryVideo

None: SDL_GetCurrentDisplayMode (last edited 2016-04-15 22:08:43 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit