Ghost Context Refactor

https://developer.blender.org/D643
Separates graphics context creation from window code in Ghost so that they can vary separately.
This commit is contained in:
Jason Wilkins
2014-10-07 15:46:19 -05:00
parent a8705e99ee
commit 8d084e8c8f
236 changed files with 63900 additions and 2614 deletions

View File

@@ -36,6 +36,11 @@ set(SRC
boost_locale_wrapper.h
)
if(APPLE)
# Cocoa code to read the locale on OSX
list(APPEND SRC osx_user_locale.mm)
endif()
if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()

View File

@@ -29,6 +29,10 @@ Import('env')
sources = env.Glob('*.cpp')
if env['OURPLATFORM'] in ['darwin']:
# Cocoa code to read user locale on OSX
sources.append('osx_user_locale.mm')
incs = '.'
defs = []

View File

@@ -65,8 +65,7 @@ void bl_locale_set(const char *locale)
}
else {
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
extern char GHOST_user_locale[128]; // pulled from Ghost_SystemCocoa
std::string locale_osx = GHOST_user_locale + std::string(".UTF-8");
std::string locale_osx = osx_user_locale() + std::string(".UTF-8");
_locale = gen(locale_osx.c_str());
#else
_locale = gen("");

View File

@@ -42,7 +42,11 @@ void bl_locale_init(const char *messages_path, const char *default_domain);
void bl_locale_set(const char *locale);
const char *bl_locale_get(void);
const char *bl_locale_pgettext(const char *msgctxt, const char *msgid);
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
const char* osx_user_locale(void);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,22 @@
#include "boost_locale_wrapper.h"
#import <Cocoa/Cocoa.h>
#include <cstdlib>
static char* user_locale = NULL;
// get current locale
const char* osx_user_locale()
{
::free(user_locale);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
NSLocale * myNSLocale = (NSLocale *) myCFLocale;
[myNSLocale autorelease];
NSString *nsIdentifier = [myNSLocale localeIdentifier];
user_locale = ::strdup([nsIdentifier UTF8String]);
[pool drain];
return user_locale;
}