Wednesday, April 8, 2009

Coming Soon -Another OpenGL Example Ported to iPhone

There's a fairly famous OpenGL tutorial that's been done in many places both online and in books, where you make a flag wave in the breeze. I needed something similar to that a project I'm working on, so I thought a good place to start would be by porting this example to the iPhone. I decided to give the project a little bit of a historical twist:



You can click the image above to see a movie. Unfortunately, because the flag is black, all the shadows I worked so hard to get working right are basically lost, so for practical reasons, this may not have been the best image choice, but you can substitute another if you prefer. I like the historical significance, even if it's not particularly practical.

In case you don't know, the flag above was a famous part of the original Macintosh team back in the early eighties. The actual flag was flown for a short time (unsanctioned by Apple) over the building that housed the Macintosh Division. It was also featured in a picture of the Mac team that ran in Fortune magazine in 1984. A movie of the flag was also hidden as an easter egg on the Install CD that came bundled with two different Quadra Mac models. You can read more about the pirate flag here.

I'll be posting the code for this a little later on. Here's one version of the flag tutorial, and here's another. I won't be doing a full tutorial on this, only talking a little about the iPhone-specific aspects and what I had to change to get it running on our favorite mobile platform.

LOL: I just noticed that my texture mapping must have the x-coordinate reversed. The patch is over the wrong eye! I'll fix that before I post the code.



5 comments:

George Sealy said...

If you want to see the shading better, you can give the flag a specular highlight or sheen. Unfortunately, by default the specular is multiplied by the colour of the texture (mostly black here) and you'll still miss the highlight.

However, OpenGL (and I hope OpenGLES) has a setting to tell the renderer to separate the specular calculations out, giving better highlights on black.

Have a look at for GL_SEPARATE_SPECULAR_COLOR in the GL docs...

Jeff LaMarche said...

I thought GL_LIGHT_MODEL_COLOR_CONTROL wasn't part of OpenGL ES... maybe I'm wrong, I'll look into it. Thanks for the suggestion.

George Sealy said...

Ah, sorry about that. Without shader support, or resorting to a two pass rendering algorithm, it was the only way I know to get a nice highlight on black...

Edwin said...

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

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