Showing posts with label Ogre3D. Show all posts
Showing posts with label Ogre3D. Show all posts

Tuesday, January 20, 2009

Develop Ogre3D applications using Eclipse on Mac OS X

This tutorial will lead you trough all the steps required to configure Eclipse for Ogre 3D applications development on Mac OS X.

Requirements
To perform the tasks described in this tutorial it is necessary for you to setup a basic development system including:
Application creation
To create your first application start Eclipse and select New -> C++ Project from the File menu.
Now select Hello World C++ Project and give it a name (let's say MyFristOgreApp).

Application configuration
The application is now created, but is not connected in any way to Ogre, thus any ogre specific code, if compiled, would give compilation, link and run-time errors.
To solve this problem you have to include the Ogre framework in your application, and make the project aware of the Ogre and Carbon frameworks position.
  1. Right-click on your project name in the Project Explorer and select Import, then select import from File System.
    Browse to the Dependencies directory of the OgreSDK folder, select the subfolders and then import it in the Frameworks subdir for your project.

  2. Now right-click again on your project name in the Project Explorer and select Properties.
    Move to C/C++ General -> Paths and Symbols and press the Add button.
    Select Frameworks/Ogre.framework/Header directory in you workspace and check Add to all configurations, Add to all languages and Is a workspace path.
    Do the same for Frameworks/Cg.framework/Header and Frameworks/include directories.
    Press Add again, select /Developer/Headers/FlatCarbon folder and check only Add to all configurations, Add to all languages this time.


  3. Move to Library Paths tab and press Add; again check Add to all configurations, Add to all languages and Is a workspace path and add Framworks/lib/Release directory.


  4. Now select C/C++ Build ->Settings from the tree menu on the left and set the configuration selector to [ All configurations ].
    Click on C++ Linker -> Libraries and add ois to Libraries


  5. Finally click on C++ Linker -> Miscellaneous and write -F${CWD}/../Frameworks -framework Ogre -framework Carbon -framework IOKit -framework Cg in the Linker flags text box.

Last bug-fix
Now your IDE is correctly configured but your application will not compile due to an error within the Frameworks/Ogre.framework/Headers/OSX/OgreTimerImp.h file. Edit this file and change the line #include <ogre/OgrePrerequisites.h> to #include <OgrePrerequisites.h>.

Conclusion and last hints
Now this setup will allow you to compile any Ogre based application, however, if you want to work with Ogre official tutorials, you have to go through some further steps:
  1. Import in you application the headers required by the tutorial you are working on (most of the times ExampleApplication.h and ExampleFrameListener.h are required).
    You can find them in the Samples directory of your OgreSDK.
  2. Import the Media directory of your OgreSDK into your project's root (this directory contains all the tutorials required textures, models, etc... )
  3. Import the .cfg files from you OgreSDK and modify them to match the path of your Media directory (typically ../Media is good).
  4. Add this command: install -d ${CWD}/Contents/Resources && cp -f ${CWD}/../*.cfg ${CWD}/Contents/Resources to your project's Post-build step (set it in the Build steps tab of the C/C++ Build -> Settings configuration form and remember to do it for all configurations)