The OpenGL ES 2.0 Programming Guide
Porting the Sample Code to the iPhone
The process of porting the sample code from the book to the iPhone highlights some of the unique features of the iPhone. In particular, some of the unique features of the development environment include:
- The use of Objective C
- The process of creating an EGL rendering context using the EAGLContext.
- Detection of device capabilities and creating an OpenGL ES 2.0 context
- The use of a framebuffer object as the primary rendering surface
Once you have created and setup a rendering context, programming with OpenGL ES 2.0 on the iPhone is identical to any other platform. However, there are some unique aspects of the platform that are worth understanding before jumping into the code.
Objective C
Apple utilizes the Objective C language within their development framework. Objective C is an object oriented language that is a superset of C. Files that are in Objective C have the .m file extension. There are a number of great tutorials online that will help you understand the fundamental differences between C/C++ and Objective C. As Objective C is the primary language used on the iPhone, you will definitely want to get an understanding of it before moving too far in development.
One of the great things about Objective C is because it is a strict superset of C, any code written in C will also compile with the Objective C compiler. The sample code in our book was all written in C so this made it quite easy to port all of the code. The main changes to the code were around the event system and EGL initialization. By and large, the core of each sample ported to the platform without modification.
Download file here