Wiki Page Content

Differences between revisions 13 and 14
Revision 13 as of 2011-03-04 23:14:00
Size: 947
Editor: SheenaSmith
Comment: update content - 2/28 5421 (2/10 5244)
Revision 14 as of 2012-05-27 02:41:01
Size: 1709
Editor: ChrisBush
Comment: Code example
Deletions are marked like this. Additions are marked like this.
Line 24: Line 24:
You can add your code example here // 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;
 
}

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