Green lines of code mean you have to add them. Struck red lines of code mean you have to remove them from the original code.
- Let's install OGRE 1.8.0 SDK for iOS.
Download it from here. Make a folder called Ogre_iOS in a folder that contains your own projects. Open the downloaded package and drag OgreSDK folder from within the package into our newly created folder Ogre_iOS. Rename it to SDK_1.8.0. I will use the folder name 'Ogre_iOS/SDK_1.8.0' to indicate the SDK root folder. - Let's create a tutorial project.
Run XCode 4.3 and from the main menu select File-New-Project. In the dialogbox that has popped up, select the [Simple View Application] in iOS-Application section as in the next picture.
Click Next button in the bottom-left corner and name the project BasicTutorial1. Click Next button and Finder dialogbox pops up to let you decide the parent folder which this project's top folder will reside in. Choose the parent folder which contains Ogre_iOS folder and then click Create button in the bottom-right corner so that 'Ogre_iOS' folder and this project's top folder are side by side.
Once the project is created, change the extensions .m to .mm of BasicTutorial1/AppDelegate.m and BasicTutorial1/Supporting Files/main.m so that we can use C++. -
Let's add the resource files to this project.
Right-click on the project heading(red rectangle in the next picture) in the left-most column and choose [Add Files to ...] on the popup menu.
In Finder dialogbox that has popped up, find 'Ogre_iOS/SDK_1.8.0/Media' folder and single-click it to stay highlighted. Among the options at the bottom, select [Create folder references ...] as in the next picture. Click Add button in the bottom-right corner of the dialogbox so that the folder structure and all the files in it will be copied into the bundle.
Again like the way we just did, add 'Ogre_iOS/SDK_1.8.0/bin/plugins.cfg' file.
Look away from XCode and by using Finder locate 'Ogre_iOS/SDK_1.8.0/bin/resources.cfg'. This time copy it into the project folder. Again like the way we just did, add the copied resources.cfg into the XCode project. - Let's edit resources.cfg.
Open it and find the line marked as red below in the middle of the text.
... FileSystem=Media/materials/textures/nvidia FileSystem=Media/models #FileSystem=Media/particle FileSystem=Media/DeferredShadingMedia ...
Insert a #(pound) sign at the beginning of the line like above. This way the line is commented out.
Find [Tests] section at the end of the text as following.... [General] FileSystem=Media
Delete the whole Test section.# Materials for visual tests [Tests] FileSystem=Media/../../Tests/Media - Let's add the include paths.
Click the project heading in the leftmost column and to the right in the second column choose the only item in the first section PROJECT. To the right at the top of the table, select [Build Settings] tab and find [Header Search Paths] row in [Search Paths] section deep in the middle of the table. Double-click the cell on the right of the row so that the input dialogbox pops up. Click the plus-sign button in the bottom-left corner of it to enable an input row and put each of the next green lines into it. Make sure you don't copy the new line character '\n' by dragging for copying.
../Ogre_iOS/SDK_1.8.0/include
../Ogre_iOS/SDK_1.8.0/include/OIS
../Ogre_iOS/SDK_1.8.0/include/OGRE
../Ogre_iOS/SDK_1.8.0/include/OGRE/iOS
../Ogre_iOS/SDK_1.8.0/include/OGRE/RenderSystems/GLES
../Ogre_iOS/SDK_1.8.0/Samples/Common/include
../Ogre_iOS/SDK_1.8.0/include/boost - Let's add the official Tutorial Framework files.
To begin with, download Tutorial Framework from here, which is under [Quick Download] title. Add the four files: BaseApplication.h, BaseApplication.cpp and TutorialApplication.h, TutorialApplication.cpp to this project and follow the instructions from the Guide [Adapt Official Ogre Tutorial Framework for iPhone(iOS)] to adapt them.
If you have gone through those instructions before, you can use your previously adapted files BaseApplication.h, BaseApplication.cpp instead. In this latter case, make sure that we have removed main() in TutorialApplication.cpp.
Otherwise, you can use the next two linked files that I modified by myself. Right-click each of the linked file names and choose the saving option like [Save Linked Stuff As ...] from your web-browser's popup menu.
- Let's add libraries for linking.
Click on the project heading in the leftmost column and to the right in the second column choose the only item in PROJECT section and again to the right at the top of the table choose [Build Settings] tab. In the long table, find [Library Search Paths] row in [Search Paths] section deep in the middle and click on the triangle shape at the beginning of the row to expand the row. Double-click the input cell on the right of Debug row among the expanded sub-rows and the input dialogbox pops up. Click the plus-sign button in the bottom-left corner of the dialogbox to activate an input row and put ../Ogre_iOS/SDK_1.8.0/lib/Debug in the activated row. For Release row next to Debug row, input ../Ogre_iOS/SDK_1.8.0/lib/Release .
Search the table for another row [Other Linker Flags] in Linking section. Single-click the input cell on the right of the row to activate it and put -lOIS -lzziplib -lFreeImage -lfreetype into it. These flags indicate the library files in both Debug and Release library folders that we previously set.
In the second column from the left, click the only item in TARGETS section and to the right at the top click [Build Phases] tab. At the third bar [Link Binary With Libraries] click on the triangle shape at the left to expand the bar and click the plus-sign button in the bottom-left corner. A dialogbox in the next picture pops up. We are going to add iOS' frameworks. Find OpenGLES.framework, QuartzCore.framework in the dialogbox and add them.
Next we are going to add Ogre's library files. Pop up the previous dialogbox again and click [Add Others ...] button in the bottom-left corner. Locate ../Ogre_iOS/SDK_1.8.0/lib/Release folder and add libOgreMainStatic.a libRenderSystem_GLESStatic.a. Locate ../Ogre_iOS/SDK_1.8.0/lib and add libboost_thread.a. - Let's integrate the framework into this project.
Delete the three files: ViewController.h .m .xib from the project and add #import <QuartzCore/QuartzCore.h> for display link.
Open AppDelegate.h and add the next two variables to class AppDelegate.class TutorialApplication ; @interface AppDelegate : UIResponder <UIApplicationDelegate> { TutorialApplication* m_pApp ; CADisplayLink* m_oDispLnk ; }
Open AppDelegate.mm and include TutorialApplication.h. Locate AppDelegate's method application:didFinishLaunchingWithOptions:. Remove the code(struck red lines) related with the view controller from it as following. Add to this method new code that creates and sets up an instance of class TutorialApplication and also add code related with Display Link which calls a new method renderOneFrame of class AppDelegate every screen refresh.- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Lastly, add code which deletes the instance when the app terminates as following.self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible];try { m_pApp = new TutorialApplication ; if ( ! m_pApp->setup() ) return NO ; m_oDispLnk = [ [UIScreen mainScreen] displayLinkWithTarget:self selector:@selector(renderOneFrame) ] ; [ m_oDispLnk addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode ] ; } catch( Ogre::Exception& e ) { NSLog( @"%s", e.getFullDescription().c_str() ) ; throw e ; } return YES; } -(void) renderOneFrame { m_pApp->get_pRoot()->renderOneFrame() ; }- (void)applicationWillTerminate:(UIApplication *)application { if( NULL != m_pApp ) { m_pApp->destroyScene() ; delete m_pApp ; m_pApp = NULL ; } }
-
Let's make this app full-screen.
Dig in the project tree from the heading in the leftmost column down to BasicTutorial/Supporting Files/BasicTutorial1-Info.plist and click it. To the right in the table, right-click on the white space under the last row and a popup menu shows up. Choose [Add Row] on the menu as in the next picture. A new row is created beneath the last row and a list box shows up as in the next picture. Scroll down the list for [Status bar is initially hidden] item and select it. Click on the spinner on the right of the newly added row as in the above picture and choose YES from the list.