///////////////////////////////////////////////////////
| 39 | |
| 40 | //////////////////////////////////////////////////////////// |
| 41 | std::vector<VideoMode> VideoModeImpl::getFullscreenModes() |
| 42 | { |
| 43 | // Retrieve all modes available for main screen only. |
| 44 | CFArrayRef cgmodes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr); |
| 45 | |
| 46 | if (cgmodes == nullptr) |
| 47 | { |
| 48 | err() << "Couldn't get VideoMode for main display." << std::endl; |
| 49 | return {}; |
| 50 | } |
| 51 | |
| 52 | const VideoMode desktop = getDesktopMode(); |
| 53 | std::vector<VideoMode> modes = {desktop}; |
| 54 | |
| 55 | // Loop on each mode and convert it into a sf::VideoMode object. |
| 56 | const CFIndex modesCount = CFArrayGetCount(cgmodes); |
| 57 | for (CFIndex i = 0; i < modesCount; ++i) |
| 58 | { |
| 59 | auto* cgmode = static_cast<CGDisplayModeRef>(const_cast<void*>(CFArrayGetValueAtIndex(cgmodes, i))); |
| 60 | |
| 61 | const VideoMode mode = convertCGModeToSFMode(cgmode); |
| 62 | |
| 63 | // Skip if bigger than desktop as we currently don't perform hard resolution switch |
| 64 | if ((mode.size.x > desktop.size.x) || (mode.size.y > desktop.size.y)) |
| 65 | continue; |
| 66 | |
| 67 | // If not yet listed we add it to our modes array. |
| 68 | if (std::find(modes.begin(), modes.end(), mode) == modes.end()) |
| 69 | modes.push_back(mode); |
| 70 | } |
| 71 | |
| 72 | // Clean up memory. |
| 73 | CFRelease(cgmodes); |
| 74 | |
| 75 | return modes; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | //////////////////////////////////////////////////////////// |