Improve CVideo::get_available_resolutions.

If there is a main window use that else fall back to the original code.

Based on a patch by AI0867.
This commit is contained in:
Mark de Wever 2014-06-21 14:17:36 +02:00
parent 572ac8ea66
commit d8409507ae

View File

@ -559,12 +559,22 @@ sdl::twindow *CVideo::get_window()
#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
static int sdl_display_index()
{
if(window) {
return SDL_GetWindowDisplayIndex(*window);
}
return 0;
}
#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
std::vector<std::pair<int, int> > CVideo::get_available_resolutions()
{
std::vector<std::pair<int, int> > result;
const int modes = SDL_GetNumDisplayModes(0);
const int modes = SDL_GetNumDisplayModes(sdl_display_index());
if(modes <= 0) {
std::cerr << "No modes supported\n";
return result;