mirror of https://github.com/OpenTTD/OpenTTD
(svn r15231) -Change: (sdl) check the full screen resolutions to determine what 'valid' resolutions we've got
parent
789fa42f52
commit
4ba90f6887
|
@ -96,7 +96,7 @@ static void DrawSurfaceToScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Dimension default_resolutions[] = {
|
static const Dimension _default_resolutions[] = {
|
||||||
{ 640, 480},
|
{ 640, 480},
|
||||||
{ 800, 600},
|
{ 800, 600},
|
||||||
{1024, 768},
|
{1024, 768},
|
||||||
|
@ -112,36 +112,33 @@ static const Dimension default_resolutions[] = {
|
||||||
|
|
||||||
static void GetVideoModes()
|
static void GetVideoModes()
|
||||||
{
|
{
|
||||||
int i;
|
SDL_Rect **modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE | SDL_FULLSCREEN);
|
||||||
SDL_Rect **modes;
|
if (modes == NULL) usererror("sdl: no modes available");
|
||||||
|
|
||||||
modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
|
_all_modes = (SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE | (_fullscreen ? SDL_FULLSCREEN : 0)) == (void*)-1);
|
||||||
|
if (modes == (void*)-1) {
|
||||||
if (modes == NULL)
|
int n = 0;
|
||||||
usererror("sdl: no modes available");
|
for (uint i = 0; i < lengthof(_default_resolutions); i++) {
|
||||||
|
if (SDL_VideoModeOK(_default_resolutions[i].width, _default_resolutions[i].height, 8, SDL_FULLSCREEN) != 0) {
|
||||||
_all_modes = (modes == (void*)-1);
|
_resolutions[n] = _default_resolutions[i];
|
||||||
|
if (++n == lengthof(_resolutions)) break;
|
||||||
if (_all_modes) {
|
}
|
||||||
// all modes available, put some default ones here
|
}
|
||||||
memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
|
_num_resolutions = n;
|
||||||
_num_resolutions = lengthof(default_resolutions);
|
|
||||||
} else {
|
} else {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (i = 0; modes[i]; i++) {
|
for (int i = 0; modes[i]; i++) {
|
||||||
int w = modes[i]->w;
|
int w = modes[i]->w;
|
||||||
int h = modes[i]->h;
|
int h = modes[i]->h;
|
||||||
if (w >= 640 && h >= 480) {
|
int j;
|
||||||
int j;
|
for (j = 0; j < n; j++) {
|
||||||
for (j = 0; j < n; j++) {
|
if (_resolutions[j].width == w && _resolutions[j].height == h) break;
|
||||||
if (_resolutions[j].width == w && _resolutions[j].height == h) break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (j == n) {
|
if (j == n) {
|
||||||
_resolutions[j].width = w;
|
_resolutions[j].width = w;
|
||||||
_resolutions[j].height = h;
|
_resolutions[j].height = h;
|
||||||
if (++n == lengthof(_resolutions)) break;
|
if (++n == lengthof(_resolutions)) break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_num_resolutions = n;
|
_num_resolutions = n;
|
||||||
|
|
Loading…
Reference in New Issue