summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoregladil <egladil@openttd.org>2007-12-29 05:15:13 +0000
committeregladil <egladil@openttd.org>2007-12-29 05:15:13 +0000
commitbb45f463550d08eb090ff104c75598f40a4c3ac0 (patch)
treedbb755e5300cf30bb52c4ff019321dbbaabb81f7
parent13ffc5b58100f7ba2f23051c96e66e53d7f079e9 (diff)
downloadopenttd-bb45f463550d08eb090ff104c75598f40a4c3ac0.tar.xz
(svn r11718) -Fix [FS#1483]: Show the fullscreen modes available to the cocoa driver in windowed mode too.
-rw-r--r--src/video/cocoa/cocoa_v.h2
-rw-r--r--src/video/cocoa/fullscreen.mm155
-rw-r--r--src/video/cocoa/wnd_quartz.mm7
-rw-r--r--src/video/cocoa/wnd_quickdraw.mm7
4 files changed, 85 insertions, 86 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index c37a1691d..3a7276bb2 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -79,4 +79,6 @@ void QZ_GameLoop();
void QZ_ShowMouse();
void QZ_HideMouse();
+uint QZ_ListModes(OTTD_Point* modes, uint max_modes, CGDirectDisplayID display_id, int display_depth);
+
#endif /* VIDEO_COCOA_H */
diff --git a/src/video/cocoa/fullscreen.mm b/src/video/cocoa/fullscreen.mm
index d03a0bf82..d7f542009 100644
--- a/src/video/cocoa/fullscreen.mm
+++ b/src/video/cocoa/fullscreen.mm
@@ -76,6 +76,86 @@ struct OTTD_QuartzGammaTable {
@end
+
+uint QZ_ListModes(OTTD_Point* modes, uint max_modes, CGDirectDisplayID display_id, int display_depth)
+{
+ CFArrayRef mode_list;
+ CFIndex num_modes;
+ CFIndex i;
+ uint count = 0;
+
+ mode_list = CGDisplayAvailableModes(display_id);
+ num_modes = CFArrayGetCount(mode_list);
+
+ /* Build list of modes with the requested bpp */
+ for (i = 0; i < num_modes && count < max_modes; i++) {
+ CFDictionaryRef onemode;
+ CFNumberRef number;
+ int bpp;
+ int intvalue;
+ bool hasMode;
+ uint16 width, height;
+
+ onemode = (const __CFDictionary*)CFArrayGetValueAtIndex(mode_list, i);
+ number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel);
+ CFNumberGetValue (number, kCFNumberSInt32Type, &bpp);
+
+ if (bpp != display_depth) continue;
+
+ number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayWidth);
+ CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
+ width = (uint16)intvalue;
+
+ number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayHeight);
+ CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
+ height = (uint16)intvalue;
+
+ /* Check if mode is already in the list */
+ {
+ uint i;
+ hasMode = false;
+ for (i = 0; i < count; i++) {
+ if (modes[i].x == width && modes[i].y == height) {
+ hasMode = true;
+ break;
+ }
+ }
+ }
+
+ if (hasMode) continue;
+
+ /* Add mode to the list */
+ modes[count].x = width;
+ modes[count].y = height;
+ count++;
+ }
+
+ /* Sort list smallest to largest */
+ {
+ uint i, j;
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < count-1; j++) {
+ if (modes[j].x > modes[j + 1].x || (
+ modes[j].x == modes[j + 1].x &&
+ modes[j].y > modes[j + 1].y
+ )) {
+ uint tmpw = modes[j].x;
+ uint tmph = modes[j].y;
+
+ modes[j].x = modes[j + 1].x;
+ modes[j].y = modes[j + 1].y;
+
+ modes[j + 1].x = tmpw;
+ modes[j + 1].y = tmph;
+ }
+ }
+ }
+ }
+
+ return count;
+}
+
+
class FullscreenSubdriver: public CocoaSubdriver {
int display_width;
int display_height;
@@ -449,80 +529,7 @@ public:
virtual uint ListModes(OTTD_Point* modes, uint max_modes)
{
- CFArrayRef mode_list;
- CFIndex num_modes;
- CFIndex i;
- uint count = 0;
-
- mode_list = CGDisplayAvailableModes(display_id);
- num_modes = CFArrayGetCount(mode_list);
-
- /* Build list of modes with the requested bpp */
- for (i = 0; i < num_modes && count < max_modes; i++) {
- CFDictionaryRef onemode;
- CFNumberRef number;
- int bpp;
- int intvalue;
- bool hasMode;
- uint16 width, height;
-
- onemode = (const __CFDictionary*)CFArrayGetValueAtIndex(mode_list, i);
- number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayBitsPerPixel);
- CFNumberGetValue (number, kCFNumberSInt32Type, &bpp);
-
- if (bpp != display_depth) continue;
-
- number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayWidth);
- CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
- width = (uint16)intvalue;
-
- number = (const __CFNumber*)CFDictionaryGetValue(onemode, kCGDisplayHeight);
- CFNumberGetValue(number, kCFNumberSInt32Type, &intvalue);
- height = (uint16)intvalue;
-
- /* Check if mode is already in the list */
- {
- uint i;
- hasMode = false;
- for (i = 0; i < count; i++) {
- if (modes[i].x == width && modes[i].y == height) {
- hasMode = true;
- break;
- }
- }
- }
-
- if (hasMode) continue;
-
- /* Add mode to the list */
- modes[count].x = width;
- modes[count].y = height;
- count++;
- }
-
- /* Sort list smallest to largest */
- {
- uint i, j;
- for (i = 0; i < count; i++) {
- for (j = 0; j < count-1; j++) {
- if (modes[j].x > modes[j + 1].x || (
- modes[j].x == modes[j + 1].x &&
- modes[j].y > modes[j + 1].y
- )) {
- uint tmpw = modes[j].x;
- uint tmph = modes[j].y;
-
- modes[j].x = modes[j + 1].x;
- modes[j].y = modes[j + 1].y;
-
- modes[j + 1].x = tmpw;
- modes[j + 1].y = tmph;
- }
- }
- }
- }
-
- return count;
+ return QZ_ListModes(modes, max_modes, display_id, display_depth);
}
virtual bool ChangeResolution(int w, int h)
diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm
index 774dcdb35..6109c46dd 100644
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -660,12 +660,7 @@ void WindowQuartzSubdriver::UpdatePalette(uint first_color, uint num_colors)
uint WindowQuartzSubdriver::ListModes(OTTD_Point* modes, uint max_modes)
{
- if (max_modes == 0) return 0;
-
- modes[0].x = window_width;
- modes[0].y = window_height;
-
- return 1;
+ return QZ_ListModes(modes, max_modes, kCGDirectMainDisplay, buffer_depth);
}
bool WindowQuartzSubdriver::ChangeResolution(int w, int h)
diff --git a/src/video/cocoa/wnd_quickdraw.mm b/src/video/cocoa/wnd_quickdraw.mm
index a331398d0..6c30900d0 100644
--- a/src/video/cocoa/wnd_quickdraw.mm
+++ b/src/video/cocoa/wnd_quickdraw.mm
@@ -685,12 +685,7 @@ void WindowQuickdrawSubdriver::UpdatePalette(uint first_color, uint num_colors)
uint WindowQuickdrawSubdriver::ListModes(OTTD_Point* modes, uint max_modes)
{
- if (max_modes == 0) return 0;
-
- modes[0].x = window_width;
- modes[0].y = window_height;
-
- return 1;
+ return QZ_ListModes(modes, max_modes, kCGDirectMainDisplay, buffer_depth);
}
bool WindowQuickdrawSubdriver::ChangeResolution(int w, int h)