Skip to content

Commit

Permalink
Added an sdl::window wrapper for SDL_GetWindowDisplayIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Dec 6, 2016
1 parent cbcb355 commit b33fc6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/sdl/window.cpp
Expand Up @@ -129,6 +129,11 @@ void window::set_minimum_size(int min_w, int min_h)
SDL_SetWindowMinimumSize(window_, min_w, min_h);
}

int window::get_display_index()
{
return SDL_GetWindowDisplayIndex(window_);
}

window::operator SDL_Window*()
{
return window_;
Expand Down
2 changes: 2 additions & 0 deletions src/sdl/window.hpp
Expand Up @@ -151,6 +151,8 @@ class window
*/
void set_minimum_size(int min_w, int min_h);

int get_display_index();

/***** ***** ***** Conversion operators. ***** ***** *****/

/**
Expand Down
15 changes: 5 additions & 10 deletions src/video.cpp
Expand Up @@ -368,20 +368,15 @@ sdl::window *CVideo::get_window()
return window.get();
}


static int sdl_display_index(sdl::window* window)
{
if(window) {
return SDL_GetWindowDisplayIndex(*window);
}
return 0;
}

std::vector<std::pair<int, int> > CVideo::get_available_resolutions(const bool include_current)
{
std::vector<std::pair<int, int> > result;

const int modes = SDL_GetNumDisplayModes(sdl_display_index(window.get()));
if(!window) {
return result;
}

const int modes = SDL_GetNumDisplayModes(window->get_display_index());
if (modes <= 0) {
std::cerr << "No modes supported\n";
return result;
Expand Down

0 comments on commit b33fc6a

Please sign in to comment.