| 164 | } |
| 165 | |
| 166 | SystemWindow::SystemWindow( Settings& settings ) |
| 167 | : settings_(settings) |
| 168 | { |
| 169 | if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) |
| 170 | Log::FatalError( "Can not initialize sdl video" ); |
| 171 | |
| 172 | GetVideoModes(); |
| 173 | |
| 174 | const bool is_opengl= ! settings.GetOrSetBool( SettingsKeys::software_rendering, true ); |
| 175 | |
| 176 | int width= 0, height= 0, scale= 1; |
| 177 | unsigned int frequency= 0u, display= 0u; |
| 178 | if( settings.GetOrSetBool( SettingsKeys::fullscreen, false ) ) |
| 179 | { |
| 180 | width = settings.GetInt( SettingsKeys::fullscreen_width , 640 ); |
| 181 | height= settings.GetInt( SettingsKeys::fullscreen_height, 480 ); |
| 182 | frequency= settings.GetInt( SettingsKeys::fullscreen_frequency, 60 ); |
| 183 | display= settings.GetInt( SettingsKeys::fullscreen_display, 0 ); |
| 184 | |
| 185 | if( displays_video_modes_.empty() ) // Abort fullscreen. |
| 186 | { |
| 187 | settings.SetSetting( SettingsKeys::fullscreen, false ); |
| 188 | goto windowed; |
| 189 | } |
| 190 | |
| 191 | if( display >= displays_video_modes_.size() ) |
| 192 | display= 0u; |
| 193 | |
| 194 | bool mode_found= false; |
| 195 | for( const VideoMode& mode : displays_video_modes_[display] ) |
| 196 | { |
| 197 | if( int(mode.size.Width()) == width && int(mode.size.Height()) == height ) |
| 198 | { |
| 199 | bool frequency_found= false; |
| 200 | for( const unsigned int f : mode.supported_frequencies ) |
| 201 | { |
| 202 | if( f == frequency ) |
| 203 | { |
| 204 | frequency_found= true; |
| 205 | break; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | if( !frequency_found ) |
| 210 | frequency= mode.supported_frequencies.empty() ? 60 : mode.supported_frequencies.front(); |
| 211 | |
| 212 | mode_found= true; |
| 213 | break; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | if( !mode_found ) // Abort fullscreen. |
| 218 | { |
| 219 | settings.SetSetting( SettingsKeys::fullscreen, false ); |
| 220 | goto windowed; |
| 221 | } |
| 222 | |
| 223 | settings.SetSetting( SettingsKeys::fullscreen_display, int(display) ); |
nothing calls this directly
no test coverage detected