summaryrefslogtreecommitdiff
path: root/src/SFML/Window/OSX/VideoModeImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/SFML/Window/OSX/VideoModeImpl.cpp')
-rw-r--r--src/SFML/Window/OSX/VideoModeImpl.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/SFML/Window/OSX/VideoModeImpl.cpp b/src/SFML/Window/OSX/VideoModeImpl.cpp
index d83d17d..94d8edd 100644
--- a/src/SFML/Window/OSX/VideoModeImpl.cpp
+++ b/src/SFML/Window/OSX/VideoModeImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -50,6 +50,8 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
return modes;
}
+ VideoMode desktop = getDesktopMode();
+
// Loop on each mode and convert it into a sf::VideoMode object.
const CFIndex modesCount = CFArrayGetCount(cgmodes);
for (CFIndex i = 0; i < modesCount; i++)
@@ -58,6 +60,10 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
VideoMode mode = convertCGModeToSFMode(cgmode);
+ // Skip if bigger than desktop as we currently don't perform hard resolution switch
+ if ((mode.width > desktop.width) || (mode.height > desktop.height))
+ continue;
+
// If not yet listed we add it to our modes array.
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
modes.push_back(mode);
@@ -73,12 +79,21 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
////////////////////////////////////////////////////////////
VideoMode VideoModeImpl::getDesktopMode()
{
+ VideoMode mode; // RVO
+
+ // Rely exclusively on mode and convertCGModeToSFMode
+ // instead of display id and CGDisplayPixelsHigh/Wide.
+
CGDirectDisplayID display = CGMainDisplayID();
- return VideoMode(CGDisplayPixelsWide(display),
- CGDisplayPixelsHigh(display),
- displayBitsPerPixel(display));
+ CGDisplayModeRef cgmode = CGDisplayCopyDisplayMode(display);
+
+ mode = convertCGModeToSFMode(cgmode);
+
+ CGDisplayModeRelease(cgmode);
+
+ return mode;
}
} // namespace priv
-
} // namespace sf
+