Ogre3D 삽질란/Basic Tutorial 6

기초 튜토리얼 6-3 (마지막)

n_Sys 2008. 11. 30. 19:02

Mac OS X

Mac OS X 어플 번들(app bundles) 사용하므로 윈도우즈나 리눅스에서 쓰이는 코드와는 근본적으로 달라집니다. 위에서 설명한 코드들은 Mac OS X에서는 동작되지 않습니다.

*                   다음 코드를 추가하세요

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE

#include <CoreFoundation/CoreFoundation.h>

 

// This function will locate the path to our application on OS X,

// unlike windows you can not rely on the curent working directory

// for locating your configuration files and resources.

std::string macBundlePath()

{

    char path[1024];

    CFBundleRef mainBundle = CFBundleGetMainBundle();

    assert(mainBundle);

       

    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);

    assert(mainBundleURL);

       

    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);

    assert(cfStringRef);

       

    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);

       

    CFRelease(mainBundleURL);

    CFRelease(cfStringRef);

       

    return std::string(path);

}

#endif

*                   부분을

mRoot = new Root();

이렇게 바꾸세요

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE

    mRoot = new Root(macBundlePath() + "/Contents/Resources/plugins.cfg");

#else

    mRoot = new Root();

#endif

*                   부분을

cf.load("resources.cfg");

이렇게 바꾸세요

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE

    cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); 

#else

    cf.load("resources.cfg");        

#endif

*                   부분을

ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);

이렇게 바꾸세요

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE

    ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName);

#else

    ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);

#endif