28 #include <SFML/Window/Cocoa/VideoModeSupport.hpp>
29 #include <ApplicationServices/ApplicationServices.h>
39 void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& Modes)
47 CFArrayRef DisplayModes = CGDisplayAvailableModes( kCGDirectMainDisplay );
48 CFIndex DisplayModeCount = CFArrayGetCount( DisplayModes );
49 CFDictionaryRef CurrentMode;
51 for (
int Count = 0; Count < DisplayModeCount; ++Count)
53 CurrentMode = (CFDictionaryRef)CFArrayGetValueAtIndex( DisplayModes, Count );
57 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(CurrentMode, kCGDisplayWidth), kCFNumberIntType, &(Mode.Width));
58 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(CurrentMode, kCGDisplayHeight), kCFNumberIntType, &(Mode.Height));
59 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(CurrentMode, kCGDisplayBitsPerPixel), kCFNumberIntType, &(Mode.BitsPerPixel));
62 if (std::find(Modes.begin(), Modes.end(), Mode) == Modes.end())
63 Modes.push_back(Mode);
71 VideoMode VideoModeSupport::GetDesktopVideoMode()
75 CFDictionaryRef CurrentVideoMode = CGDisplayCurrentMode(kCGDirectMainDisplay);
77 VideoMode DesktopMode;
81 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(CurrentVideoMode, kCGDisplayWidth),
83 &(DesktopMode.Width));
86 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(CurrentVideoMode, kCGDisplayHeight),
88 &(DesktopMode.Height));
91 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(CurrentVideoMode, kCGDisplayBitsPerPixel),
93 &(DesktopMode.BitsPerPixel));