SDL_GetCurrentVideoDisplay

Name

SDL_GetCurrentVideoDisplay -- Get the index of the currently selected display.

Synopsis

#include "SDL_video.h"

int SDL_GetCurrentVideoDisplay (void);

Description

SDL_GetCurrentVideoDisplay gets the index of the currently selected display.

Return Value

Returns the index of the currently selected display.

Example

   1 #include "SDL.h"
   2 #include <stdio.h>
   3 
   4 int main(int argc, char** argv) {
   5   int numdisplays, defaultdisplay, i;
   6   int nummodes, j;
   7   SDL_DisplayMode mode;
   8   
   9   if (SDL_Init(SDL_INIT_VIDEO) != 0) {
  10     printf("Error initializing SDL:  %s\n", SDL_GetError());
  11     return 1;
  12   }
  13   atexit(SDL_Quit);
  14 
  15   numdisplays = SDL_GetNumVideoDisplays();
  16   defaultdisplay = SDL_GetCurrentVideoDisplay();
  17   printf("Currently using display %d.\n", defaultdisplay);
  18   
  19   for (i = 0; i < numdisplays; ++i) {
  20     printf("\nEnumerating modes for display %d\n", i);
  21     SDL_SelectVideoDisplay(i);
  22     nummodes = SDL_GetNumDisplayModes();
  23     for (j = 0; j < nummodes; ++j) {
  24       SDL_GetDisplayMode(j, &mode);
  25       printf("  Mode %d:  %dx%d %dHz %d bpp\n", j, mode.w, mode.h, mode.refresh_rate, SDL_BITSPERPIXEL(mode.format));
  26     }
  27     printf("  %d modes.\n", nummodes);
  28   }
  29   SDL_SelectVideoDisplay(defaultdisplay);
  30   
  31   printf("\n%d displays.\n", numdisplays);
  32 }

See Also

SDL_GetNumVideoDisplays, SDL_SelectVideoDisplay


CategorySDL13API CategorySDL13APIVideo

SDL-1.3/SDL_GetCurrentVideoDisplay (last edited 2009-07-31 03:00:41 by KenBull)