Many of the frameworks listed below are written in the C++ language. C++ is an object-oriented superset of C, much like Objective-C is. It is one of the most popular programming languages and can be used directly in your iOS programs.

  • Source code header files always use the .h extension.
  • Source code implementation files written in pure C and Objective-C use the .m extension.
  • Source code implementation files written in C++ use the .cpp extension.
  • Source code implementation files written in in both Objective-C and C++ use the .mm extension.

C++ is a very powerful language that is less abstracted than Objective-C. This means that it will generally be more complicated but offer better performance. One of the main differences you might notice is that you’ll have to manually manage your memory (allocations and deallocations). However, most of the frameworks listed below include some type of reference counting.


openFrameworks is an open source C++ toolkit for creative coding. Its design is heavily influenced by Processing, which should make many of the functions familiar to you. openFrameworks was originally created for high-performance graphics and video processing, but can be used for a variety of applications.

A few years ago, openFrameworks was ported to iOS, allowing desktop applications to run on mobile devices without changing a single line of code. Many successful iOS apps are built with openFrameworks, such as SpellTower.

One of the strengths of openFrameworks is its large user base and their dedication to open source software. You can find a long list of contributed addons which can help you perform a variety of tasks. If you’re stuck on a problem, you can browse through the forum or post a new question, and it will most probably be answered within the hour.

You can download the iOS version of openFrameworks here and follow the setup guide to get started. This solution will create an app that is “openFrameworks driven”, meaning that most of your code (if not all) will be part of the openFrameworks project. Alternatively, you can use the ofxiOS addon, which treats openFrameworks projects similarly to other views, and keeps your app “Objective-C driven”.


Cinder is another creative coding library for C++. The main difference with openFrameworks is that it uses more specific system libraries instead of opting for cross-platform open-source solutions. This will usually result in better performance but is more complex to use and code. Cinder also makes heavy use of C++ namespaces, which can be confusing and hard to read. Cinder is aimed and experienced developers, so it’s harder to get into if you don’t know what you are doing.

There are a few Cinder apps in the App Store, notably DMesh and Planetary.

The Mac version of Cinder can be downloaded here and includes compilation targets for iOS.


pocode is yet another C++ library for interactive media. Whereas openFrameworks and Cinder are all about high performance graphics, pocode’s strength lies in interface design. It borrows a page from Flash where every object has spatial properties (position, rotation, scale), built-in event handlers, and a cascading parent-child relationship.

pocode for Mac can be downloaded here and includes iOS templates and compilation targets.


C4iOS is the newcomer to the game, having only been released a few months ago. It is also a creative coding toolkit, but unlike the frameworks listed above, C4iOS is written in Objective-C. Instead of having to switch in and out of a special C++ view, you can simply use C4iOS objects directly in your code. As the name implies, C4iOS is also iOS specific and works seamlessly with multitouch interactions and gestures.

Although C4iOS still does not have a very large user base, it has very clear and complete documentation, including examples and tutorials. It’s also Canadian, so +1 for that :)

C4iOS can be downloaded from here.


Cocos2D is an open source game engine that has been ported to many different languages and platforms, including Objective-C for iOS. It only supports 2D, meaning that it’s a great toolkit to build a puzzler or platformer, but not ideal for a shooter.

Cocos2D simplifies the process of creating scenes in apps (for example a menu scene, a game scene, a high score scene, etc.) It uses OpenGL ES for rendering and can easily incorporate one of two robust and popular physics engines: Box2D and Chipmunk.

Cocos2D has been used by many games and apps in the App Store, including FarmVille, Trainyard, and Björk’s Biophilia.

Cocos2D can be downloaded from here.


Unity is a multi-platform game engine with a port for iOS. It is the industry standard for developing high performance, complex games, and its $1500 price reflects that. You can however download a limited version free-of-charge, but will still need the $400 iOS plugin.

Unity projects are built in C#. It can be used to build 2D and 3D environments and includes a multitude of plugins for animation, modeling, physics, etc.

Unity is used for many games in the App Store, such as Triple Town and Shadowgun.


The Open Graphics Library (OpenGL) is a framework for rendering 2D and 3D graphics. OpenGL usually interacts directly with the GPU, achieving hardware-accelerated rendering. OpenGL is a cross-platform, multi-language API and it is widely used in visualization software and video games.

OpenGL ES is the version of the library that runs on embedded devices such as the iPhone and iPad. It is a subset of desktop implementations of OpenGL. There are two versions of OpenGL ES available for use on iOS. Version 1.1 uses a fixed pipeline, meaning that you use a set of built-in functions to build your scene. Version 2.0 uses a programmable pipeline, meaning that there are no built-in functions and everything must be built from scratch. As you’ve probably guessed, 2.0 is a lot more complicated but allows for more control than 1.1. For this lesson, we’ll be using version 1.1 as we’re just getting our hands dirty with OpenGL.

The OpenGL API for iOS is written in pure C, much like the Core Graphics framework, and integrates seamlessly with Objective-C classes. You need to link against three additional frameworks to use OpenGL code in your apps: Quartz Core, OpenGL ES, and GLKit.

GL View

GLKView is a UIView subclass used to render OpenGL graphics.

The GLKView needs to be attached to an EAGLContext. This is a drawing context, which manages all of the data iOS needs to draw with OpenGL.

The GLKView must also be connected to a GLKViewDelegate, which will be polled periodically to draw content in the view. This is done by implementig the glkView:drawInRect: method.

We can try pulsing the red background by using a couple of variables to set the color.

You’ll notice that this does not work as expected, and that is because glkView:drawInRect: is not called regularly. Similarly to drawInRect:, this method is only called when the view is first shown, when it is resized, etc.

When using OpenGL, you will often need to redraw the view at every frame. We need to replace the default redraw behaviour by another that redraws in sync with the screen refresh rate. This can be achieved using a CADisplayLink timer.

GL View Controller

We just saw how to build and render to a GL view from scratch. GLKit offers a much easier solution for doing this using a GLKViewController. This is a UIViewController subclass that also implements an OpenGL ES rendering loop. The GLKViewController will create the GLKView and set itself as its delegate automatically, but you still need to set the EAGLContext manually.

Header Source

At this point, it’s a good idea to cleanly initialize and destroy the context.

GLKViewController also provides us with an update method, which is called every frame like the draw method, but intended for app logic.

GLKViewController allows us to set the desired frame rate using the preferredFramesPerSecond property. Note that the actual frame rate may be lower than this, depending on how long it takes to render a frame. The actual frame rate can be read using the framesPerSecond property.

Drawing Shapes

Rendering geometry in OpenGL is done using vertices (points). Vertices can have multiple properties such as position, colour, texture coordinates, etc. These vertices can be passed to the buffer using many different methods. We will use one of the simplest called vertex arrays.

Note that the origin (0, 0) is set to the center of the view by default.

OpenGL ES can only render triangles, so you will often need to combine multiple triangles to build the desired shape.

As we are only working in 2D, we can get rid of the z-coordinate.

We can set the shape color using glColor4f(). This will change the color of anything that is drawn until the next call to glColor4f().

We can also set the color on a vertex-by-vertex basis by passing a color array along with the vertex array.

We can optimize our data by removing duplicate points. We can then use an index array to indicate the order in which the vertices should be drawn.

  1. Beginning OpenGL ES 2.0 with GLKit Part 1. Ray Wenderlick, Oct 19 2011.
  2. OpenGL ES Programming Guide for iOS. Apple, Feb 24 2011.