|
| 1 | +Table of contents |
| 2 | +================= |
| 3 | + |
| 4 | +* [Overview](#overview) |
| 5 | +* [Video](#video) |
| 6 | +* [Steps](#steps) |
| 7 | + |
| 8 | + * [1.9.1. Create build directory](#step-build-dir) |
| 9 | + * [1.9.2. Launch CMake](#step-open-cmake) |
| 10 | + * [1.9.3. Specify build and source directories](#step-dirs) |
| 11 | + * [1.9.4. Configure osgNativeLib and OSG](#step-cfg) |
| 12 | + * [1.9.5. Generate Xcode project file](#step-generate) |
| 13 | + * [1.9.6. Build osgNativeLib and OSG](#step-build) |
| 14 | + * [1.9.7. Start a new Xcode project](#step-xcode) |
| 15 | + * [1.9.8. Select Single View Application](#step-single-view) |
| 16 | + * [1.9.9. Select Objective-C language](#step-objc) |
| 17 | + * [1.9.10. Finish project creation](#step-proj) |
| 18 | + * [1.9.11. Copy combined library](#step-copy-lib) |
| 19 | + * [1.9.12. Copy view controller and model](#step-copy) |
| 20 | + * [1.9.13. Add copied files to the project](#step-add) |
| 21 | + * [1.9.14. Select RenderVC as the main interface](#step-main) |
| 22 | + * [1.9.15. Reference osgNativeLib headers](#step-headers) |
| 23 | + * [1.9.16. Run the project](#step-run) |
| 24 | + |
| 25 | +<a name="overview"/> |
| 26 | + |
| 27 | +Overview |
| 28 | +======== |
| 29 | + |
| 30 | +This tutorial is part of [OpenSceneGraph cross-platform guide](http://github.com/OGStudio/openscenegraph-cross-platform-guide). |
| 31 | + |
| 32 | +In this tutorial we build and run |
| 33 | +[sample OpenSceneGraph application](http://github.com/OGStudio/openscenegraph-cross-platform-guide-application) |
| 34 | +under Linux for Web. The application displays provided model with simple GLSL shaders. |
| 35 | + |
| 36 | +**Note**: this tutorial requires |
| 37 | +* OpenSceneGraph model (see [1.1. Create a cube](../1.1.CreateCube)) |
| 38 | +* OpenSceneGraph sources (see [1.2. Install OpenSceneGraph under Linux](../1.2.InstallUnderLinux)) |
| 39 | +* sample OpenSceneGraph application sources (see [1.5. Build and run sample OpenSceneGraph application under Linux](../1.5.SampleUnderLinux)) |
| 40 | + |
| 41 | +<a name="video"/> |
| 42 | + |
| 43 | +Video |
| 44 | +===== |
| 45 | + |
| 46 | +[YouTube](todo) | [Download](readme/video.mp4) |
| 47 | + |
| 48 | +Video depicts running and building sample OpenSceneGraph application |
| 49 | +for Web under Xubuntu 16.04. |
| 50 | + |
| 51 | +<a name="steps"/> |
| 52 | + |
| 53 | +Steps |
| 54 | +===== |
| 55 | + |
| 56 | +**Note**: steps below use frames from the video as screenshots. |
| 57 | +Watch the video to see all details. |
| 58 | + |
| 59 | +<a name="step-build-dir"/> |
| 60 | + |
| 61 | +1.9.1. Create build directory |
| 62 | +----------------------------- |
| 63 | + |
| 64 | +  |
| 65 | + |
| 66 | + Create build directory for iOS simulator build of osgNativeLib, |
| 67 | + a native C++ library to be used in Objective-C. |
| 68 | + |
| 69 | + osgNativeLib also builds OpenSceneGraph inside |
| 70 | + `/path/to/openscenegraph-cross-platform-guide-application/../OpenSceneGraph/build/Simulator`. |
| 71 | + |
| 72 | + **Note**: iOS simulator build only works under iOS simulator. If you need |
| 73 | + to build for a real device, you need to build osgNativeLib |
| 74 | + with `BUILD_SIMULATOR=NO` in a separate directory. In such a case |
| 75 | + OpenSceneGraph is built inside |
| 76 | + `/path/to/openscenegraph-cross-platform-guide-application/../OpenSceneGraph/build/Device`. |
| 77 | + |
| 78 | +<a name="step-open-cmake"/> |
| 79 | + |
| 80 | +1.9.2. Launch CMake |
| 81 | +------------------- |
| 82 | + |
| 83 | +  |
| 84 | + |
| 85 | + Open CMake |
| 86 | + |
| 87 | +<a name="step-dirs"/> |
| 88 | + |
| 89 | +1.9.3. Specify build and source directories |
| 90 | +------------------------------------------- |
| 91 | + |
| 92 | +  |
| 93 | + |
| 94 | + Specify build and source directories. |
| 95 | + |
| 96 | +<a name="step-cfg"/> |
| 97 | + |
| 98 | +1.9.4. Configure osgNativeLib and OSG |
| 99 | +------------------------------------- |
| 100 | + |
| 101 | +  |
| 102 | + |
| 103 | + Press `Configure`. Select `Xcode` generator when prompted. |
| 104 | + |
| 105 | +<a name="step-generate"/> |
| 106 | + |
| 107 | +1.9.5. Generate Xcode project file |
| 108 | +----------------------------------- |
| 109 | + |
| 110 | +  |
| 111 | + |
| 112 | + Press `Generate` to generate Xcode specific project file. |
| 113 | + |
| 114 | +<a name="step-build"/> |
| 115 | + |
| 116 | +1.9.6. Build osgNativeLib and OSG |
| 117 | +--------------------------------- |
| 118 | + |
| 119 | +  |
| 120 | + |
| 121 | + Build osgNativeLib and OpenSceneGraph with the following commands: |
| 122 | + |
| 123 | + `cd /path/to/build/dir` |
| 124 | + |
| 125 | + `xcodebuild -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=8 -configuration Release` |
| 126 | + |
| 127 | + At the end the build process combines osgNativeLib and several OpenSceneGraph |
| 128 | + libraries into single `libosglib.a` library. This is done for convenience. |
| 129 | + |
| 130 | +<a name="step-xcode"/> |
| 131 | + |
| 132 | +1.9.7. Start a new Xcode project |
| 133 | +-------------------------------- |
| 134 | + |
| 135 | +  |
| 136 | + |
| 137 | + Start a new Xcode project. |
| 138 | + |
| 139 | +<a name="step-single-view"/> |
| 140 | + |
| 141 | +1.9.8. Select Single View Application |
| 142 | +-------------------------------- |
| 143 | + |
| 144 | +  |
| 145 | + |
| 146 | + Select Single View Application. |
| 147 | + |
| 148 | +<a name="step-objc"/> |
| 149 | + |
| 150 | +1.9.9. Select Objective-C language |
| 151 | +---------------------------------- |
| 152 | + |
| 153 | +  |
| 154 | + |
| 155 | + Select Objective-C language and provide application specific |
| 156 | + information like title, organization, etc. |
| 157 | + |
| 158 | +<a name="step-proj"/> |
| 159 | + |
| 160 | +1.9.10. Finish project creation |
| 161 | +------------------------------- |
| 162 | + |
| 163 | +  |
| 164 | + |
| 165 | + Select project directory and finish project creation. |
| 166 | + |
| 167 | +<a name="step-copy-lib"/> |
| 168 | + |
| 169 | +1.9.11. Copy combined library |
| 170 | +----------------------------- |
| 171 | + |
| 172 | +  |
| 173 | + |
| 174 | + Copy combined library into project directory with the following command: |
| 175 | + |
| 176 | + `cp /path/to/build/dir/libosglib.a /path/to/xcode/project/subdir/` |
| 177 | + |
| 178 | +<a name="step-copy"/> |
| 179 | + |
| 180 | +1.9.12. Copy view controller and model |
| 181 | +-------------------------------------- |
| 182 | + |
| 183 | +  |
| 184 | + |
| 185 | + Copy view controller and model with the following command: |
| 186 | + |
| 187 | + `cp -R /path/to/openscenegraph-cross-platform-guide-application/ios/project/* /path/to/xcode/project/subdir` |
| 188 | + |
| 189 | + Sample OpenSceneGraph application's *ios/project* directory contains |
| 190 | + a box model and `RenderVC`. `RenderVC` is a view controller that renders |
| 191 | + the model with osgNativeLib. |
| 192 | + |
| 193 | +<a name="step-add"/> |
| 194 | + |
| 195 | +1.9.13. Add copied files to the project |
| 196 | +--------------------------------------- |
| 197 | + |
| 198 | +  |
| 199 | + |
| 200 | + For Xcode to see the files, they should be added to the project. |
| 201 | + |
| 202 | +<a name="step-main"/> |
| 203 | + |
| 204 | +1.9.14. Select RenderVC as the main interface |
| 205 | +--------------------------------------------- |
| 206 | + |
| 207 | +  |
| 208 | + |
| 209 | + Go to `General` project page and select `RenderVC.storyboard` as |
| 210 | + the main interface. |
| 211 | + |
| 212 | +<a name="step-headers"/> |
| 213 | + |
| 214 | +1.9.15. Reference osgNativeLib headers |
| 215 | +-------------------------------------- |
| 216 | + |
| 217 | +  |
| 218 | + |
| 219 | + Since we have not added osgNativeLib headers to the project, we should |
| 220 | + reference them to be able to call osgNativeLib functions. |
| 221 | + |
| 222 | + Go to project's `Build Settings`, find `Header Search Paths` section, |
| 223 | + then add the following search paths: |
| 224 | + |
| 225 | + `/path/to/openscenegraph-cross-platform-guide-application/ios/src` |
| 226 | + |
| 227 | + `/path/to/openscenegraph-cross-platform-guide-application/ios/src-gen` |
| 228 | + |
| 229 | +<a name="step-run"/> |
| 230 | + |
| 231 | +1.9.16. Run the project |
| 232 | +----------------------- |
| 233 | + |
| 234 | +  |
| 235 | + |
| 236 | + Select iPhone simulator and run the project. |
| 237 | + You should see red cube displayed. |
| 238 | + |
0 commit comments