[...] here: Qixis.com » Blog Archive » 3d engine tutorial, part 1 Share and [...]
[...] related posts Qixis blog 3d engine tutorial, part 2 3d engine tutorial, part 1 announcing: Qixis::Engine 3d engine tutorial, part [...]
Before starting work on a big task like building a 3d engine, it’s probably a good idea to decide which tools and programming language you are going to use. Of course, this being an engine for the iPhone, the choices are a bit limited.
First, we’re going to need a development environment and an SDK for the iPhone. Apple’s official iPhone SDK contains XCode, an excellent Integrated Development Environment. It comes complete with an iPhone simulator, making debugging and testing of software a lot easier. Also, it integrates with Shark and Instruments to do some basic performance profiling. And best of all, as long as you don’t mind developing in just the simulator, it’s free too. It’s Mac only, so if you’re using Windows you’re a bit out of luck here… As far as I know iPhone development can only be done on a Mac.
Second, we’re going to choose a language to use. I’m not an experienced Objective C programmer, but I know my way around C++. On Mac and iPhone development, it’s not really possible to avoid the use of Objective C altogether, but it’s easy to mix it with C++. So, I’ll write the iPhone specific bits in Objective C (ObjC from now on) and the bits that have any potential to be platform independent in C++. I think this is good practice if one possibly wants to use their code on other platforms in the future. All the maths code and a good portion of the OpenGL code in the engine is platform independent and compiles and runs fine on Linux. The engine has some preparations to separate the platform-dependent rendering from the platform-independent bits. We’ll get to that later.
If you don’t know any ObjC or C++ you are going to find these tutorials hard to follow. If you know some of it and just need an online reference, here are some good ones:
- C – http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/
- Objective C – http://www.otierney.net/objective-c.html
- Objective C – http://cocoadevcentral.com/d/learn_objectivec/
- C++ – http://www.cplusplus.com/doc/tutorial/
C and ObjC are relatively easy to learn. C++ is a very difficult but very powerful language.
So, that’s all settled. XCode will be the development environment, ObjC and C++ the languages.
- Download XCode with iPhone SDK here.
Also, to follow this tutorial, you need a copy of Qixis::Engine (known as ‘the engine’) from now on. This is the version of the engine as it is in my subversion repository on august 20, 2009. It’s not finished, and we’ll finish it as we go…
- Download Qixis::Engine XCode project here (version 2009.08.20).
Before continuing, install the iPhone SDK if you’ve not already done so. If the installer asks any difficult questions, all the default answers are OK.
Unzip the file ‘Engine-2009.08.20.zip’ to a location that’s convenient for you. For me, it’s a folder ‘Programming/iPhone’ in my home directory. After unzipping, open ‘Engine3d.xcodeproj’. XCode fires up and presents you with a screen looking more or less like the following:
To build, make sure the iPhone simulator target is selected.
If all goes well, press cmd-R. XCode compiles everything and creates an iPhone executable. It automatically starts up the simulator and should present you with something looking like this:
That’s it for now. You now have the development version of the engine, exactly as I have it. I recommend to just look around the code a bit to familiarize yourself with its structure. The interesting files at this moment are ‘Engine.cpp’, ‘Node.cpp’ and ‘Square.cpp’.
In the next part of this series I’ll take you through all the files and describe what they do and how they fit in the engine’s architecture.
‘Till next time!


