Skip to content

Instantly share code, notes, and snippets.

@thecoder08
Created January 23, 2024 02:10
Show Gist options
  • Save thecoder08/1cc17aeeba037db8cf401bae735439f3 to your computer and use it in GitHub Desktop.
Save thecoder08/1cc17aeeba037db8cf401bae735439f3 to your computer and use it in GitHub Desktop.
List SDL2 video and audio drivers.
#include <SDL2/SDL.h>
#include <stdio.h>
int main() {
puts("Available video drivers:");
int numVideoDrivers = SDL_GetNumVideoDrivers();
for (int i = 0; i < numVideoDrivers; i++) {
puts(SDL_GetVideoDriver(i));
}
puts("Available audio drivers:");
int numAudioDrivers = SDL_GetNumAudioDrivers();
for (int i = 0; i < numAudioDrivers; i++) {
puts(SDL_GetAudioDriver(i));
}
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
printf("Currently using audio driver %s\n", SDL_GetCurrentAudioDriver());
printf("Currently using video driver %s\n", SDL_GetCurrentVideoDriver());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment