You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include <SDL2/SDL.h>
  2. #include <vector>
  3. int main(){
  4. int nVDrvNumber = 0;
  5. //if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
  6. // printf( "SDL_Init Error: %s \n", SDL_GetError() );
  7. // return EXIT_FAILURE;
  8. //}
  9. SDL_Init( 0 );
  10. std::vector< bool > drivers( SDL_GetNumVideoDrivers() );
  11. for( int i = 0; i < drivers.size(); ++i ){
  12. drivers[ i ] = ( 0 == SDL_VideoInit( SDL_GetVideoDriver( i ) ) );
  13. SDL_VideoQuit();
  14. };
  15. printf( "SDL_VIDEODRIVER usable: " );
  16. for( int i = 0; i < drivers.size(); ++i ){
  17. if( !drivers[ i ] ) continue;
  18. printf( " %s", SDL_GetVideoDriver( i ) );
  19. };
  20. printf( "\n" );
  21. nVDrvNumber = SDL_GetNumVideoDrivers();
  22. printf( "Number of Video Drivers: %d\n", nVDrvNumber );
  23. if( nVDrvNumber ){
  24. for( int j = 0; j < nVDrvNumber; j++ ){
  25. printf( "Driver[%d]:%s\n", j, SDL_GetVideoDriver( j ) );
  26. };
  27. };
  28. if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_blit")) {
  29. printf( "Use Blit\n" );
  30. //draw_to_the_screen_with_framebuffer_blit(); // faster!
  31. } else {
  32. printf( "No Blit!\n" );
  33. //draw_to_the_screen_with_a_textured_quad(); // slower!
  34. };
  35. if( SDL_VideoInit("directfb") != 0 ){
  36. printf("Error initializing SDL video: %s\n", SDL_GetError());
  37. return 2;
  38. };
  39. static int display_in_use = 0; /* Only using first display */
  40. int i, display_mode_count;
  41. SDL_DisplayMode mode;
  42. Uint32 f;
  43. SDL_Log("SDL_GetNumVideoDisplays(): %i", SDL_GetNumVideoDisplays());
  44. display_mode_count = SDL_GetNumDisplayModes(display_in_use);
  45. if (display_mode_count < 1) {
  46. SDL_Log("SDL_GetNumDisplayModes failed: %s", SDL_GetError());
  47. return 1;
  48. }
  49. SDL_Log("SDL_GetNumDisplayModes: %i", display_mode_count);
  50. for (i = 0; i < display_mode_count; ++i) {
  51. if (SDL_GetDisplayMode(display_in_use, i, &mode) != 0) {
  52. SDL_Log("SDL_GetDisplayMode failed: %s", SDL_GetError());
  53. return 1;
  54. }
  55. f = mode.format;
  56. SDL_Log("Mode %i\tbpp %i\t%s\t%i x %i", i,
  57. SDL_BITSPERPIXEL(f), SDL_GetPixelFormatName(f), mode.w, mode.h);
  58. }
  59. SDL_Quit();
  60. return 0;
  61. };