SDL_GetNumVideoDrivers
Name
SDL_GetNumVideoDrivers -- Get the number of video drivers.
Synopsis
#include "SDL_video.h" int SDL_GetNumVideoDrivers (void);
Description
SDL_GetNumVideoDrivers gets the number of video drivers compiled into SDL.
Return Value
Returns the number of video drivers.
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 }
