SDL_GetVideoDriver

Name

SDL_GetVideoDriver -- Get the name of a video driver.

Synopsis

#include "SDL_video.h"

const char* SDL_GetVideoDriver (int index);

Description

SDL_GetVideoDriver gets the name of a built in video driver.

Return Value

Returns a pointer to a null terminated string containing the name of a video driver or NULL if index is less than 0 or not less than the value returned by SDL_GetNumVideoDrivers.

Note: The video drivers are presented in the order in which they are normally checked during initialization.

Example

   1 #include "SDL.h"
   2 #include <stdio.h>
   3 
   4 int main(int argc, char** argv) {
   5   int numdrivers, i, working;
   6   const char* drivername;
   7   
   8   if (SDL_Init(0) != 0) {
   9     printf("Error initializing SDL:  %s\n", SDL_GetError());
  10     return 1;
  11   }
  12   atexit(SDL_Quit);
  13   
  14   numdrivers = SDL_GetNumVideoDrivers();
  15   working = 0;
  16   
  17   for (i = 0; i < numdrivers; ++i) {
  18     drivername = SDL_GetVideoDriver(i);
  19     
  20     if (SDL_VideoInit(drivername, 0) == 0) {
  21       SDL_VideoQuit();
  22       ++working;
  23       printf("Driver %s works.\n", drivername);
  24     }
  25     else {
  26       printf("Driver %s doesn't work.\n", drivername);
  27     }
  28   }
  29   
  30   printf("\n%d video drivers total (%d work)\n", numdrivers, working);
  31   
  32   return 0;
  33 }

See Also

SDL_GetNumVideoDrivers, SDL_GetCurrentVideoDriver, SDL_VideoInit


CategorySDL13API CategorySDL13APIVideo

SDL-1.3/SDL_GetVideoDriver (last edited 2009-07-30 02:30:50 by KenBull)