equal
deleted
inserted
replaced
94 else |
94 else |
95 SDL_CALL SDL_UpdateRects(_sdl_screen, n, _dirty_rects); |
95 SDL_CALL SDL_UpdateRects(_sdl_screen, n, _dirty_rects); |
96 } |
96 } |
97 } |
97 } |
98 |
98 |
99 static const uint16 default_resolutions[][2] = { |
99 static const Dimension default_resolutions[] = { |
100 { 640, 480}, |
100 { 640, 480}, |
101 { 800, 600}, |
101 { 800, 600}, |
102 {1024, 768}, |
102 {1024, 768}, |
103 {1152, 864}, |
103 {1152, 864}, |
104 {1280, 800}, |
104 {1280, 800}, |
132 int w = modes[i]->w; |
132 int w = modes[i]->w; |
133 int h = modes[i]->h; |
133 int h = modes[i]->h; |
134 if (w >= 640 && h >= 480) { |
134 if (w >= 640 && h >= 480) { |
135 int j; |
135 int j; |
136 for (j = 0; j < n; j++) { |
136 for (j = 0; j < n; j++) { |
137 if (_resolutions[j][0] == w && _resolutions[j][1] == h) break; |
137 if (_resolutions[j].width == w && _resolutions[j].height == h) break; |
138 } |
138 } |
139 |
139 |
140 if (j == n) { |
140 if (j == n) { |
141 _resolutions[j][0] = w; |
141 _resolutions[j].width = w; |
142 _resolutions[j][1] = h; |
142 _resolutions[j].height = h; |
143 if (++n == lengthof(_resolutions)) break; |
143 if (++n == lengthof(_resolutions)) break; |
144 } |
144 } |
145 } |
145 } |
146 } |
146 } |
147 _num_resolutions = n; |
147 _num_resolutions = n; |
158 // all modes available? |
158 // all modes available? |
159 if (_all_modes) return; |
159 if (_all_modes) return; |
160 |
160 |
161 // is the wanted mode among the available modes? |
161 // is the wanted mode among the available modes? |
162 for (i = 0; i != _num_resolutions; i++) { |
162 for (i = 0; i != _num_resolutions; i++) { |
163 if (*w == _resolutions[i][0] && *h == _resolutions[i][1]) return; |
163 if (*w == _resolutions[i].width && *h == _resolutions[i].height) return; |
164 } |
164 } |
165 |
165 |
166 // use the closest possible resolution |
166 // use the closest possible resolution |
167 best = 0; |
167 best = 0; |
168 delta = abs((_resolutions[0][0] - *w) * (_resolutions[0][1] - *h)); |
168 delta = abs((_resolutions[0].width - *w) * (_resolutions[0].height - *h)); |
169 for (i = 1; i != _num_resolutions; ++i) { |
169 for (i = 1; i != _num_resolutions; ++i) { |
170 uint newdelta = abs((_resolutions[i][0] - *w) * (_resolutions[i][1] - *h)); |
170 uint newdelta = abs((_resolutions[i].width - *w) * (_resolutions[i].height - *h)); |
171 if (newdelta < delta) { |
171 if (newdelta < delta) { |
172 best = i; |
172 best = i; |
173 delta = newdelta; |
173 delta = newdelta; |
174 } |
174 } |
175 } |
175 } |
176 *w = _resolutions[best][0]; |
176 *w = _resolutions[best].width; |
177 *h = _resolutions[best][1]; |
177 *h = _resolutions[best].height; |
178 } |
178 } |
179 |
179 |
180 #ifndef ICON_DIR |
180 #ifndef ICON_DIR |
181 #define ICON_DIR "media" |
181 #define ICON_DIR "media" |
182 #endif |
182 #endif |
439 |
439 |
440 SDL_CALL SDL_VideoDriverName(buf, 30); |
440 SDL_CALL SDL_VideoDriverName(buf, 30); |
441 DEBUG(driver, 1, "SDL: using driver '%s'", buf); |
441 DEBUG(driver, 1, "SDL: using driver '%s'", buf); |
442 |
442 |
443 GetVideoModes(); |
443 GetVideoModes(); |
444 CreateMainSurface(_cur_resolution[0], _cur_resolution[1]); |
444 CreateMainSurface(_cur_resolution.width, _cur_resolution.height); |
445 MarkWholeScreenDirty(); |
445 MarkWholeScreenDirty(); |
446 |
446 |
447 SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
447 SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
448 SDL_CALL SDL_EnableUNICODE(1); |
448 SDL_CALL SDL_EnableUNICODE(1); |
449 return NULL; |
449 return NULL; |
532 |
532 |
533 bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen) |
533 bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen) |
534 { |
534 { |
535 _fullscreen = fullscreen; |
535 _fullscreen = fullscreen; |
536 GetVideoModes(); // get the list of available video modes |
536 GetVideoModes(); // get the list of available video modes |
537 if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) { |
537 if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) { |
538 // switching resolution failed, put back full_screen to original status |
538 // switching resolution failed, put back full_screen to original status |
539 _fullscreen ^= true; |
539 _fullscreen ^= true; |
540 return false; |
540 return false; |
541 } |
541 } |
542 return true; |
542 return true; |