| 144 | } |
| 145 | |
| 146 | SDL_DisplayMode GetNearestDisplayMode(Size preferredSize) |
| 147 | { |
| 148 | SDL_DisplayMode nearestDisplayMode; |
| 149 | if (SDL_GetWindowDisplayMode(ghMainWnd, &nearestDisplayMode) != 0) |
| 150 | ErrSdl(); |
| 151 | |
| 152 | int displayIndex = SDL_GetWindowDisplayIndex(ghMainWnd); |
| 153 | int modeCount = SDL_GetNumDisplayModes(displayIndex); |
| 154 | for (int modeIndex = 0; modeIndex < modeCount; modeIndex++) { |
| 155 | SDL_DisplayMode displayMode; |
| 156 | if (SDL_GetDisplayMode(displayIndex, modeIndex, &displayMode) != 0) |
| 157 | continue; |
| 158 | |
| 159 | int diffHeight = std::abs(nearestDisplayMode.h - preferredSize.height) - std::abs(displayMode.h - preferredSize.height); |
| 160 | int diffWidth = std::abs(nearestDisplayMode.w - preferredSize.width) - std::abs(displayMode.w - preferredSize.width); |
| 161 | if (diffHeight < 0) |
| 162 | continue; |
| 163 | if (diffHeight == 0 && diffWidth < 0) |
| 164 | continue; |
| 165 | nearestDisplayMode = displayMode; |
| 166 | } |
| 167 | |
| 168 | return nearestDisplayMode; |
| 169 | } |
| 170 | #endif |
| 171 | |
| 172 | void CalculateUIRectangle() |
no test coverage detected