Get Updates By E-mail 

porting

Converting An iPhone App Into A Native iPad App

  •  
  •  
  •  
  •  
  •  

It’s no secret that are iPad apps are a hot commodity right now.  While most iPhone apps work on the iPad there really is no comparison to native iPad apps.  They look better, and with iPad specific UI elements added they are better for the end user.

Ray Wenderlich, the creator of the Space Game Starter Kit and co-author of the Learning Cocos2D book, has written a great easy tutorial on porting an iPhone app to the iPad, that utilizes autosizing, and native iPad interface elements.

[Source: Ray Wenderlich]


  •  
  •  
  •  
  •  
  •  

Porting OpenGL glVertex Code to Iphone OpenGL ES

  •  
  •  
  •  
  •  
  •  

Continuing where I left off yesterday I will describe some of the potential hangups when converting OpenGL code to OpenGL ES. The first thing I noticed when trying to convert some OpenGL code to the iPhone’s OpenGL ES was that on the iPhone there is no glVertex function.  Instead of glVertex you will need to use a vertex array.  I’ll give an example from Nehe Tutorial #2.

For example, in Nehe OpenGL tutorial #2 you see the lines:

glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();

What these lines do is create a triangle with the vertices specified through the glVertex3f function (3 dimensional locations).

In OpenGL ES the glBegin and glEnd, and glVertex functions do not exist, the above lines would be rewritten using a vertex array.
In my remake of the Nehe Tutorial #2 for iPhone this is done using the following lines:

const GLfloat triangleVertices[] = {
0.0f,   1.0f,   0.0f,
-1.0f,  -1.0f,  0.0f,
1.0f,   -1.0f,  0.0f
};

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, triangleVertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);

Here, an array is created, and then in order to draw the array we:

1. use glEnableClientState to enable use of a vertex array
2. use glVertexPointer to specify the size, datatype of the points stored in the array, and name of the array.
3. use glDrawArrays to draw the vertex array, in this case using the 3 points to draw a connected triangle.

Now you can see that this code provides the exact same result, just in OpenGL ES they’ve removed all redundancies so you need to use vertex arrays, and the glBegin, and glEnd semantics are removed.  Next I’ll be exploring the differences using perspective functions in OpenGL ES.


  •  
  •  
  •  
  •  
  •