Wednesday, June 24, 2009

Empty OpenGL ES Application Project Template Updated for 3.0

I have updated my OpenGL ES Xcode project to work with SDK 3.0. You can find the new version right here.

This new version is actually a rewrite from the ground up, and it fixes several issues that the old one had, including the problem where the controller wasn't receiving touch events and, of course, the fact that it didn't work on 3.0. It also includes more OpenGL-related convenience functions, and a class that makes it easier to do texture mapping.


Nicolas Goles said...

Thanks for this Jeff, I'm working on a game on your template version 1. Has really helped me, I'm still learning OpenGL ES so lot's of stuff "just works" for me, but still I'm experiencing good results and learning :)

Zip Games said...

Hey jeff,
Just wondering, what was the bug that you fixed in the new 3.0 update for the touch events? Could you specify the code exactly? I looked through the new code, but I didn't really see anything that would look like it fixes the issue.

michael.kussmaul said...

Not sure, if I'm wrong, but it seems to me there is a memory leak in your new template: In your "initWithCoder" initializer you basically alloc the context two times.


Jeff LaMarche said...


You are right, sir. When I added the conditionals to check whether OpenGL ES 2.0 was supported, I must have copied rather than cut when rearranging the code, and the context is being double allocated if you tell it to try to create an OpenGL ES 2.0 context.

Thanks for catching that, I'll fix it and get it re-posted.


Jeff LaMarche said...


Since I started from scratch, I'm not actually 100% sure how I fixed that problem. I went to look at it, and when I tested it, the problem didn't exist in the new version.

My guess is that the old version wasn't actually using the nib, so you probably need to manually set enable interactions on the view, but that's just a guess.


Cody Ng said...

Excellent! Thanks Jeff!!! You are the god.

AlBlue said...

You have

const GLfloat zNear = 0.01, zFar = 1000.0, fieldOfView = 45.0;

in the GLViewController.m, but you define the same constant (values) in ConstantsAndMacros.h. Should you use kNear and kFar?

brosno said...

Hi Jeff,
thanks for releasing this! Your articles on openGL are most helpful.

I have a question regarding how the empty OpenGL sample is organised.
It doesn't seem to follow MVC guidelines (for example, Apple's own at, and I was just wondering if there was a reason for that? (If not, I might rejig the code a bit in my own use of it).

To explain more about what I mean: your view controller class is actually doing the one doing the painting. The view actually gets the paint request, but it sends it to the view delegate, which is actually the view controller. According to usual MVC stuff, the View (or a subclass of it) should know how to paint itself. Because the view delegate is held by the view, you end with the view actually having a reference to the controllers, and not vice versa, which seems unusual.

Any clarifications gratefuly received, and thanks!

oscar said...

Excellent template, thanks a lot!

I guess you meant to use glClearColor, not glColor4f in drawView. I was very confused when I changed the numbers and nothing happened.

jodytversky said...

My colleagues and I are building a medical application for the iPhone. The application has an important 3D Model component to it but we are not very well experienced in that area. Right now we have about 10 models that were designed in studio max and exported as 4000 verticie obj files with triangles. We use obj2opengl script to convert the models and load into the app. It works pretty well. We add a few lights and a color and it looks pretty good. Here's where the problem is. For some of our complex anatomical models we actually have two or three models to load simultaneously. One for the body, another for bones and another for organs for example. The script we use scales all the models to fit the screen. This auto scaling is a problem because the organ become as big as the whole body. Does anyone know how to chnage the scaling for each independent model? Can we add a unique color to each object in the scene? Can we add a separate transparency or opaqness value to each object?

Is there another source or expert consulting team that could help us with this?

Thanks - Jody

Edwin said...

scrub m65 kamagra attorney lawyer body scrub field jacket lovegra marijuana attorney injury lawyer

Lucas Mendes said...

Jeff, how are you doing ? :)

I noticed that the mesh is being rendered w/ some kind of alpha. Do you know how could I turn off this transparency ?

Already tried glDisable(GL_BLEND) w/ no sucess..


h4ns said...

What youre saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what youre trying to say. Im sure youll reach so many people with what youve got to say.

Arsenal vs Huddersfield Town live streaming
Arsenal vs Huddersfield Town live streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Notts County vs Manchester City Live Streaming
Notts County vs Manchester City Live Streaming
Bologna vs AS Roma Live Streaming
Bologna vs AS Roma Live Streaming
Juventus vs Udinese Live Streaming
Juventus vs Udinese Live Streaming
Napoli vs Sampdoria Live Streaming
Napoli vs Sampdoria Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
AS Monaco vs Marseille Live Streaming
AS Monaco vs Marseille Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Technology News | News Today | Live Streaming TV Channels