src/video/cocoa/cocoa_v.mm
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6871 5a9dc001e1ad
child 10724 68a692eacf22
equal deleted inserted replaced
6871:5a9dc001e1ad 6872:1c4a4a609f85
    55 
    55 
    56 #include "../../stdafx.h"
    56 #include "../../stdafx.h"
    57 #include "../../openttd.h"
    57 #include "../../openttd.h"
    58 #include "../../debug.h"
    58 #include "../../debug.h"
    59 #include "../../variables.h"
    59 #include "../../variables.h"
       
    60 #include "../../core/geometry_type.hpp"
    60 #include "cocoa_v.h"
    61 #include "cocoa_v.h"
    61 #include "../../blitter/factory.hpp"
    62 #include "../../blitter/factory.hpp"
    62 #include "../../fileio.h"
    63 #include "../../fileio.h"
    63 
    64 #include "../../gfx_func.h"
    64 #undef Point
       
    65 #undef Rect
       
    66 
    65 
    67 
    66 
    68 @interface OTTDMain : NSObject
    67 @interface OTTDMain : NSObject
    69 @end
    68 @end
    70 
    69 
   197 
   196 
   198 
   197 
   199 static void QZ_UpdateVideoModes()
   198 static void QZ_UpdateVideoModes()
   200 {
   199 {
   201 	uint i, count;
   200 	uint i, count;
   202 	OTTDPoint modes[32];
   201 	OTTD_Point modes[32];
   203 
   202 
   204 	assert(_cocoa_subdriver != NULL);
   203 	assert(_cocoa_subdriver != NULL);
   205 
   204 
   206 	count = _cocoa_subdriver->ListModes(modes, lengthof(modes));
   205 	count = _cocoa_subdriver->ListModes(modes, lengthof(modes));
   207 
   206 
   230 
   229 
   231 static CocoaSubdriver *QZ_CreateWindowSubdriver(int width, int height, int bpp)
   230 static CocoaSubdriver *QZ_CreateWindowSubdriver(int width, int height, int bpp)
   232 {
   231 {
   233 	CocoaSubdriver *ret;
   232 	CocoaSubdriver *ret;
   234 
   233 
       
   234 #ifdef ENABLE_COCOA_QUARTZ
   235 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
   235 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
   236 	if (MacOSVersionIsAtLeast(10, 4, 0)) {
   236 	/* The reason for the version mismatch is due to the fact that the 10.4 binary needs to work on 10.5 as well. */
       
   237 	if (MacOSVersionIsAtLeast(10, 5, 0)) {
   237 		ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
   238 		ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
   238 		if (ret != NULL) return ret;
   239 		if (ret != NULL) return ret;
   239 	}
   240 	}
   240 #endif
   241 #endif
   241 
   242 #endif
       
   243 
       
   244 #ifdef ENABLE_COCOA_QUICKDRAW
   242 	ret = QZ_CreateWindowQuickdrawSubdriver(width, height, bpp);
   245 	ret = QZ_CreateWindowQuickdrawSubdriver(width, height, bpp);
   243 	if (ret != NULL) return ret;
   246 	if (ret != NULL) return ret;
       
   247 #endif
       
   248 
       
   249 #ifdef ENABLE_COCOA_QUARTZ
       
   250 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
       
   251         /*
       
   252 	 * If we get here we are running 10.4 or earlier and either openttd was compiled without the quickdraw driver
       
   253 	 * or it failed to load for some reason. Fall back to Quartz if possible even though that driver is slower.
       
   254 	 */
       
   255         if (MacOSVersionIsAtLeast(10, 4, 0)) {
       
   256                 ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
       
   257                 if (ret != NULL) return ret;
       
   258         }
       
   259 #endif
       
   260 #endif
   244 
   261 
   245 	return NULL;
   262 	return NULL;
   246 }
   263 }
   247 
   264 
   248 
   265 
   342 	QZ_UpdateVideoModes();
   359 	QZ_UpdateVideoModes();
   343 
   360 
   344 	return ret;
   361 	return ret;
   345 }
   362 }
   346 
   363 
   347 void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
   364 bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
   348 {
   365 {
   349 	bool oldfs;
   366 	bool oldfs;
   350 
   367 
   351 	assert(_cocoa_subdriver != NULL);
   368 	assert(_cocoa_subdriver != NULL);
   352 
   369 
   367 	}
   384 	}
   368 
   385 
   369 	QZ_GameSizeChanged();
   386 	QZ_GameSizeChanged();
   370 
   387 
   371 	QZ_UpdateVideoModes();
   388 	QZ_UpdateVideoModes();
       
   389 	return _cocoa_subdriver->IsFullscreen() == full_screen;
   372 }
   390 }
   373 
   391 
   374 
   392 
   375 /* This is needed since sometimes assert is called before the videodriver is initialized */
   393 /* This is needed since sometimes assert is called before the videodriver is initialized */
   376 void CocoaDialog(const char* title, const char* message, const char* buttonLabel)
   394 void CocoaDialog(const char* title, const char* message, const char* buttonLabel)