2727// Headers
2828// //////////////////////////////////////////////////////////
2929#include < SFML/Window/VideoModeImpl.hpp>
30+ #include < SFML/Window/OSX/DisplayImpl.hpp>
3031#include < SFML/Window/OSX/cg_sf_conversion.hpp>
3132#include < SFML/System/Err.hpp>
3233#include < algorithm>
@@ -43,64 +44,9 @@ namespace priv
4344// //////////////////////////////////////////////////////////
4445std::vector<VideoMode> VideoModeImpl::getFullscreenModes ()
4546{
46- # if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
47+ DisplayImpl display ( CGMainDisplayID ());
4748
48- std::vector<VideoMode> modes;
49-
50- // Retrieve array of dictionaries representing display modes.
51- CFArrayRef displayModes = CGDisplayAvailableModes (CGMainDisplayID ());
52-
53- if (displayModes == NULL ) {
54- sf::err () << " Couldn't get VideoMode for main display." ;
55- return modes;
56- }
57-
58- // Loop on each mode and convert it into a sf::VideoMode object.
59- CFIndex const modesCount = CFArrayGetCount (displayModes);
60- for (CFIndex i = 0 ; i < modesCount; i++) {
61- CFDictionaryRef dictionary = (CFDictionaryRef)CFArrayGetValueAtIndex (displayModes, i);
62-
63- VideoMode mode = convertCGModeToSFMode (dictionary);
64-
65- // If not yet listed we add it to our modes array.
66- if (std::find (modes.begin (), modes.end (), mode) == modes.end ()) {
67- modes.push_back (mode);
68- }
69- }
70-
71- return modes;
72-
73- #else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
74-
75- std::vector<VideoMode> modes;
76-
77- // Retrieve all modes available for main screen only.
78- CFArrayRef cgmodes = CGDisplayCopyAllDisplayModes (CGMainDisplayID (), NULL );
79-
80- if (cgmodes == NULL ) {
81- sf::err () << " Couldn't get VideoMode for main display." ;
82- return modes;
83- }
84-
85- // Loop on each mode and convert it into a sf::VideoMode object.
86- CFIndex const modesCount = CFArrayGetCount (cgmodes);
87- for (CFIndex i = 0 ; i < modesCount; i++) {
88- CGDisplayModeRef cgmode = (CGDisplayModeRef)CFArrayGetValueAtIndex (cgmodes, i);
89-
90- VideoMode mode = convertCGModeToSFMode (cgmode);
91-
92- // If not yet listed we add it to our modes array.
93- if (std::find (modes.begin (), modes.end (), mode) == modes.end ()) {
94- modes.push_back (mode);
95- }
96- }
97-
98- // Clean up memory.
99- CFRelease (cgmodes);
100-
101- return modes;
102-
103- #endif
49+ return display.getModes ();
10450}
10551
10652
0 commit comments