equal
deleted
inserted
replaced
232 int i; |
232 int i; |
233 SDL_Rect **modes; |
233 SDL_Rect **modes; |
234 |
234 |
235 modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0)); |
235 modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0)); |
236 |
236 |
237 _all_modes = (int)modes == -1; |
237 if(modes == NULL) |
238 |
|
239 if(!modes) { |
|
240 error("sdl: no modes available"); |
238 error("sdl: no modes available"); |
241 } else if((int) modes == -1) { |
239 |
|
240 _all_modes = (modes == (void*)-1); |
|
241 |
|
242 if (_all_modes) { |
242 // all modes available, put some default ones here |
243 // all modes available, put some default ones here |
243 memcpy(_resolutions, default_resolutions, sizeof(default_resolutions)); |
244 memcpy(_resolutions, default_resolutions, sizeof(default_resolutions)); |
244 _num_resolutions = sizeof(default_resolutions) / (sizeof(uint16)*2); |
245 _num_resolutions = lengthof(default_resolutions); |
245 } else { |
246 } else { |
246 int n = 0; |
247 int n = 0; |
247 for(i = 0; modes[i]; i++) { |
248 for(i = 0; modes[i]; i++) { |
248 int w = modes[i]->w; |
249 int w = modes[i]->w; |
249 int h = modes[i]->h; |
250 int h = modes[i]->h; |
255 if (_resolutions[j][0] == w && _resolutions[j][1] == h) |
256 if (_resolutions[j][0] == w && _resolutions[j][1] == h) |
256 break; |
257 break; |
257 if (j == n) { |
258 if (j == n) { |
258 _resolutions[n][0] = w; |
259 _resolutions[n][0] = w; |
259 _resolutions[n][1] = h; |
260 _resolutions[n][1] = h; |
260 if (++n == sizeof(_resolutions) / (sizeof(uint16)*2)) break; |
261 if (++n == lengthof(_resolutions)) break; |
261 } |
262 } |
262 } |
263 } |
263 } |
264 } |
264 _num_resolutions = n; |
265 _num_resolutions = n; |
265 qsort(_resolutions, n, sizeof(uint16)*2, compare_res); |
266 qsort(_resolutions, n, sizeof(_resolutions[0]), compare_res); |
266 } |
267 } |
267 } |
268 } |
268 |
269 |
269 static int GetAvailableVideoMode(int *w, int *h) |
270 static int GetAvailableVideoMode(int *w, int *h) |
270 { |
271 { |