sdldisplayquery.cpp 889 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * sdldisplayquery.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "sdldisplayquery.h"
  12. #include <QString>
  13. #include <QTextStream>
  14. #include <SDL.h>
  15. #include <SDL_video.h>
  16. QStringList getDisplays()
  17. {
  18. if(SDL_Init(SDL_INIT_VIDEO))
  19. return QStringList("default display");
  20. const int displays = SDL_GetNumVideoDisplays();
  21. QStringList list;
  22. for (int display = 0; display < displays; ++display)
  23. {
  24. SDL_Rect rect;
  25. if (SDL_GetDisplayBounds (display, &rect))
  26. continue;
  27. QString string;
  28. QTextStream(&string) << display << " - " << rect.w << "x" << rect.h << " (at " << rect.x << ", " << rect.y << ")";
  29. list << string;
  30. }
  31. SDL_Quit();
  32. return list;
  33. }