src/video/cocoa_v.mm
branchgamebalance
changeset 9913 e79cd19772dd
parent 9895 7bd07f43b0e3
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
    69 #include "../macros.h"
    69 #include "../macros.h"
    70 #include "../os/macosx/splash.h"
    70 #include "../os/macosx/splash.h"
    71 #include "../variables.h"
    71 #include "../variables.h"
    72 #include "cocoa_v.h"
    72 #include "cocoa_v.h"
    73 #include "cocoa_keys.h"
    73 #include "cocoa_keys.h"
       
    74 #include "../blitter/factory.hpp"
       
    75 #include "../fileio.h"
    74 
    76 
    75 #undef Point
    77 #undef Point
    76 #undef Rect
    78 #undef Rect
    77 
    79 
    78 /* Taken from ../gfx.h */
    80 /* Taken from ../gfx.h */
   948 @end
   950 @end
   949 
   951 
   950 
   952 
   951 static void QZ_UpdateWindowPalette(uint start, uint count)
   953 static void QZ_UpdateWindowPalette(uint start, uint count)
   952 {
   954 {
       
   955 	/* We can only update the palette in 8bpp for now */
       
   956 	/* TODO -- We need support for other bpps too! */
       
   957 	if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() != 8) return;
       
   958 
   953 	uint i;
   959 	uint i;
   954 
   960 
   955 	switch (_cocoa_video_data.device_bpp) {
   961 	switch (_cocoa_video_data.device_bpp) {
   956 		case 32:
   962 		case 32:
   957 			for (i = start; i < start + count; i++) {
   963 			for (i = start; i < start + count; i++) {
  1724 	return ret;
  1730 	return ret;
  1725 }
  1731 }
  1726 
  1732 
  1727 static void QZ_VideoInit()
  1733 static void QZ_VideoInit()
  1728 {
  1734 {
       
  1735 	if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
       
  1736 
  1729 	memset(&_cocoa_video_data, 0, sizeof(_cocoa_video_data));
  1737 	memset(&_cocoa_video_data, 0, sizeof(_cocoa_video_data));
  1730 
  1738 
  1731 	/* Initialize the video settings; this data persists between mode switches */
  1739 	/* Initialize the video settings; this data persists between mode switches */
  1732 	_cocoa_video_data.display_id = kCGDirectMainDisplay;
  1740 	_cocoa_video_data.display_id = kCGDirectMainDisplay;
  1733 	_cocoa_video_data.save_mode  = CGDisplayCurrentMode(_cocoa_video_data.display_id);
  1741 	_cocoa_video_data.save_mode  = CGDisplayCurrentMode(_cocoa_video_data.display_id);
  2045 	if (!wasstarted) CocoaVideoStop();
  2053 	if (!wasstarted) CocoaVideoStop();
  2046 
  2054 
  2047 	_cocoa_video_dialog = false;
  2055 	_cocoa_video_dialog = false;
  2048 }
  2056 }
  2049 
  2057 
       
  2058 /* This is needed since OS X application bundles do not have a
       
  2059  * current directory and the data files are 'somewhere' in the bundle */
       
  2060 void cocoaSetApplicationBundleDir()
       
  2061 {
       
  2062 	char tmp[MAXPATHLEN];
       
  2063 	CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
       
  2064 	if (CFURLGetFileSystemRepresentation(url, true, (unsigned char*)tmp, MAXPATHLEN)) {
       
  2065 		AppendPathSeparator(tmp, lengthof(tmp));
       
  2066 		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = strdup(tmp);
       
  2067 	} else {
       
  2068 		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
       
  2069 	}
       
  2070 
       
  2071 	CFRelease(url);
       
  2072 }
       
  2073 
  2050 /* These are called from main() to prevent a _NSAutoreleaseNoPool error when
  2074 /* These are called from main() to prevent a _NSAutoreleaseNoPool error when
  2051  * exiting before the cocoa video driver has been loaded
  2075  * exiting before the cocoa video driver has been loaded
  2052  */
  2076  */
  2053 void cocoaSetupAutoreleasePool()
  2077 void cocoaSetupAutoreleasePool()
  2054 {
  2078 {