Requirements: Apple xcode dmg
First step: build irrlicht
- Download the latest irrlicht 1.5.1. Navigate to the source/Irrlicht/MacOSX folder. Open MacOSX.xcodeproj in Xcode.
- In the top dropdown, switch to “Release” Active Configuration. In the top right search for IrrCompileConfig header file and open it. Scroll down a few pages until you see the Joy stick enable marco, and comment out #define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
- Push Build and Go. Grab a cup of tea or something; this will take a few minutes.
- Copy the folder include to /usr/include/irrlicht. It’s easy to do this with terminal with this command: sudo cp irrlicht1.5/include /usr/include/
- Open Xcode. New Project > Other > Empty Project
- Call it HelloWorld and save it inside the 01-HelloWorld folder
- Project > new Target. Select Carbon > Application. Call it HelloWorld too.
- It should popup with project settings (in the Project Menu) . add “/usr/X11R6/include /usr/include/irrlicht” to your Header Search Path
- Add the libraries you need. Drag the new libIrrlicht.a you created from source/Irrlicht/MacOSX/release/ into your project. Then click the Action (gear wheel) next to the drop down and goto Add -> add Existing Framework. Add Carbon, Cocoa and OpenGL.
- Add the resources needed for your .app file. Drag Sydney.bmp and Sydney.md2 into your project in the Products folder. Drag the main.cpp in there as well.
- Modify main.cpp. after #include <irrlicht.h>, add:
Code: Select all
#ifdef _IRR_OSX_PLATFORM_
#include <OpenGL/OpenGL.h>
#pragma comment(lib, "libIrrlicht.a")
#endif
After you create your device, navigate to your Resources folder inside your app file.
Code: Select all
#ifdef _IRR_OSX_PLATFORM_
device->getFileSystem ()->changeWorkingDirectoryTo ("HelloWorld.app");
device->getFileSystem ()->changeWorkingDirectoryTo ("Contents");
device->getFileSystem ()->changeWorkingDirectoryTo ("Resources");
#endif
And now if you’ve done everything right, when you hit Build and Go, you should see sydeny waiving hi to you.
Troubleshooting:
Code: Select all
"_IOServiceGetMatchingServices", referenced from:
irr::CIrrDeviceMacOSX::activateJoysticks(irr::core::array<irr::SJoystickInfo, irr::core::irrAllocator<irr::SJoystickInfo> >&)in libIrrlicht.a(CIrrDeviceMacOSX.o)
etc means that you compiled irrlicht in debug mode. Recompile in Release
Code: Select all
"_IORegistryEntryGetParentEntry", referenced from:
getJoystickDeviceInfo(unsigned int, __CFDictionary*, JoystickInfo*)in libIrrlicht.a(CIrrDeviceMacOSX.o)
getJoystickDeviceInfo(unsigned int, __CFDictionary*, JoystickInfo*)in libIrrlicht.a(CIrrDeviceMacOSX.o)
File could not be found or my screen is blank
You are not navigating to the .app folder directory. You must use changeWorkingDirectoryTo to get to the right folder, use device->getFileSystem()->getWorkingDirectory() to debug where your current folder is.
TODO:
Figure out how MacOSX handles missing lib files (does the app need to contain the .a file?)