Skip to content

Commit

Permalink
Improve CVideo::get_available_resolutions.
Browse files Browse the repository at this point in the history
If there is a main window use that else fall back to the original code.

Based on a patch by AI0867.
  • Loading branch information
mordante committed Jun 21, 2014
1 parent 572ac8e commit d840950
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/video.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit d840950

Please sign in to comment.