- Overview
- Video
- Steps
- 1.9.1. Create build directory
- 1.9.2. Launch CMake
- 1.9.3. Specify build and source directories
- 1.9.4. Configure osgNativeLib and OSG
- 1.9.5. Generate Xcode project file
- 1.9.6. Build osgNativeLib and OSG
- 1.9.7. Start a new Xcode project
- 1.9.8. Select Single View Application
- 1.9.9. Select Objective-C language
- 1.9.10. Finish project creation
- 1.9.11. Copy combined library
- 1.9.12. Copy view controller and model
- 1.9.13. Add copied files to the project
- 1.9.14. Select RenderVC as the main interface
- 1.9.15. Reference osgNativeLib headers
- 1.9.16. Run the project
This tutorial is part of OpenSceneGraph cross-platform guide.
In this tutorial we build and run sample OpenSceneGraph application under iOS. The application displays provided model with simple GLSL shaders.
Note: this tutorial requires
- OpenSceneGraph model (see 1.1. Create a cube)
- Xcode and CMake installations (see 1.4. Install OpenSceneGraph under macOS)
- OpenSceneGraph sources (see 1.4. Install OpenSceneGraph under macOS)
- sample OpenSceneGraph application sources (see 1.7. Build and run sample OpenSceneGraph application under macOS) alongside OpenSceneGraph sources
Video depicts running and building sample OpenSceneGraph application for iOS simulator with iOS 10.
Note: steps below use frames from the video as screenshots. Watch the video to see all details.
Create build directory for iOS simulator build of osgNativeLib, a native C++ library to be used in Objective-C.
osgNativeLib also builds OpenSceneGraph inside
/path/to/openscenegraph-cross-platform-guide-application/../OpenSceneGraph/build/Simulator
.
Note: iOS simulator build only works under iOS simulator. If you need
to build for a real device, you need to build osgNativeLib
with BUILD_SIMULATOR=NO
in a separate directory. In such a case
OpenSceneGraph is built inside
/path/to/openscenegraph-cross-platform-guide-application/../OpenSceneGraph/build/Device
.
Open CMake
Specify build and source directories.
Press Configure
. Select Xcode
generator when prompted.
Press Generate
to generate Xcode specific project file.
Build osgNativeLib and OpenSceneGraph with the following commands:
cd /path/to/build/dir
xcodebuild -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=8 -configuration Release
At the end the build process combines osgNativeLib and several OpenSceneGraph
libraries into single libosglib.a
library. This is done for convenience.
Start a new Xcode project.
Select Single View Application.
Select Objective-C language and provide application specific information like title, organization, etc.
Select project directory and finish project creation.
Copy combined library into project directory with the following command:
cp /path/to/build/dir/libosglib.a /path/to/xcode/project/subdir/
Copy view controller and model with the following command:
cp -R /path/to/openscenegraph-cross-platform-guide-application/ios/project/* /path/to/xcode/project/subdir
Sample OpenSceneGraph application's ios/project directory contains
a box model and RenderVC
. RenderVC
is a view controller that renders
the model with osgNativeLib.
For Xcode to see the files, they should be added to the project.
Go to General
project page and select RenderVC.storyboard
as
the main interface.
Since we have not added osgNativeLib headers to the project, we should reference them to be able to call osgNativeLib functions.
Go to project's Build Settings
, find Header Search Paths
section,
then add the following search paths:
/path/to/openscenegraph-cross-platform-guide-application/ios/src
/path/to/openscenegraph-cross-platform-guide-application/ios/src-gen
Select iPhone simulator and run the project. You should see red cube displayed.