mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-05 11:13:26 +00:00
Port CVideo::get_available_resolutions to SDL2.
The code is only compiled, but probably also works.
This commit is contained in:
parent
1ad881dac3
commit
1857ba5449
@ -518,6 +518,30 @@ void CVideo::set_window_icon(surface& icon)
|
||||
}
|
||||
#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);
|
||||
if(modes <= 0) {
|
||||
std::cerr << "No modes supported\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_DisplayMode mode;
|
||||
for(int i = 0; i < modes; ++i) {
|
||||
if(SDL_GetDisplayMode(0, i, &mode) == 0) {
|
||||
result.push_back(std::make_pair(mode.w, mode.h));
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(result.begin(), result.end());
|
||||
result.erase(std::unique(result.begin(), result.end()), result.end());
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
std::vector<std::pair<int, int> > CVideo::get_available_resolutions()
|
||||
{
|
||||
std::vector<std::pair<int, int> > result;
|
||||
@ -564,6 +588,7 @@ std::vector<std::pair<int, int> > CVideo::get_available_resolutions()
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
surface& CVideo::getSurface()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user