[iPhone Dev] 2D Games, OpenGL or Quartz?

At first, I'm truly sorry if this is the wrong area to ask this, I couldn't find anywhere else where to post it.

I have recently started building interest for the iPhone/iPod Touch development and have made a concept of a game which I want to work out.

My past experiences with programming is a bit of C and a lot of C++. And as for graphics libraries, I know SDL very well and very little bit of OpenGL usage, but not much in that area since it seemed way more work than SDL at that time. ;p

I've been a 2D programmer since the start, am not really interested in 3D for some reason.
Just to try it out I have looked at a downloadable source from Apple, a OpenGL using game called "CrashLanding", and that sort of made little sense. But so did SDL when I just started it so I really want to get into this area of development.

Now I know the iPhone gives two options for graphics (I'm gonna exclude CoreAnimation); Quartz and OpenGL ES.

So my question really is, what would be best to go with when developing 2D games for the iPhone/iPod Touch platform?

(Also as a side question, does anyone know any good tutorials to start with when going into iPhone/Touch development? I know the docs and sources are a very good place to start, but sometimes non-professionals have more useful comments and explanations. No offense to anyone though. )

Quartz may be somewhat GPU powered, but it's almost certainly going to be CPU intensive compared to using OpenGL. A CPU intensive iPhone app means that you will drain the battery quickly, and probably not run smoothly as it's not a fast processor.

Considering that GL and Quartz have similar learning curves, you might as well just go with GL.

That has set things a bit more straight for me, at least now I know what to learn!

I had another question though, even though OpenGL ES is kind of a stripped down version of OpenGL; will learning OpenGL for desktop usage be the same as on the iPhone/Touch? Or will I specifically need to learn things about OpenGL ES?

There are good NeHe tutorials in OpenGL but am not sure if I can apply the things they teach to the iPhone/Touch

I'd say it's best to first learn OpenGL ES and then "real" OpenGL (although I don't know anyone who actually did so). You can use all OpenGL ES knowledge on the desktop, but the other way round there's a good chance you'll get used to things like immediate mode, display lists and similar, which don't work in OpenGL ES (and aren't a good idea on the desktop either, as far as I know).

I'll be going for OpenGL ES then, except I'm wondering where I may be able to find good tutorials about them? I've googled around a bit but can't find anything useful, found one thing that was about a pocketpc2003 but that looked nothing like or at least very different from what I saw in the source files of the iPhone games.

Or would I need to purchase books? (Poor student here, I hate money! )

I have to say I agree that starting with OpenGL ES is probably better than desktop GL. I like it for its simplicity, and it still has great features and power and most of what you do with ES will translate directly to desktop (there are some special features depending on the platform though). I can't think of any tutorials on it right now, but I'm sure you'll see a lot more in the months ahead.

But... I must say that I think skipping CoreAnimation on iPhone is not wise IMHO. For iPhone development I forced myself to learn some CA so that I could better fit in with the UI look and feel of the iPhone, and I have to say I really, really like it a lot! It was a huge surprise to me just how easy and smooth it is to use -- far easier than picking up OpenGL. Right now I'm using a liberal combination of OpenGL for 3D stuff and CoreAnimation for 2D (and UI) stuff on the iPhone. From what I've used of it so far, I think could be a perfect solution for 2D games on the iPhone. I wouldn't dare say much more about it until it's out of beta, other than to suggest others give CA a fair chance for 2D animation before jumping all the way to OpenGL on iPhone.

After thinking about this for a few moments, I think I can say this one technical aspect of CoreAnimation without violating NDA, which might not be so obvious to some:

With OpenGL you will typically (depending on your implementation) set up a single timer to render a scene repeatedly, without stopping. That takes more processing power than only rendering when needed. CoreAnimation's timers start and stop as needed, so that if you have a static scene with nothing moving, it won't waste battery. This isn't quite as important to consider with traditional desktop systems, a little more so with laptops I suppose, but with mobile devices such as iPhone it can become critical. Now, this is not to say that you can't do the same thing with OpenGL, but you will have to put in the extra effort to implement it yourself, whereas with CoreAnimation it's automatically there for you behind the scenes.

AnotherJake Wrote:With OpenGL you will typically (depending on your implementation) set up a single timer to render a scene repeatedly, without stopping. That takes more processing power than only rendering when needed. CoreAnimation's timers start and stop as needed, so that if you have a static scene with nothing moving, it won't waste battery.

That's exactly what I'm looking for!
With SDL I had a pretty easy programming way;

... I dunno, those guys don't appear to be "Mac" developers, and they apparently do not speak English as a first language (at least not very well).

bronxbomber92 Wrote:(am I allowed to post this?)

Probably not an issue as long as *you* are not divulging technical details of iPhone which have not already been made public by Apple. That said, it is obviously better not to say anything at all if in doubt. Besides, this whole NDA mess should be over with in a few weeks -- we assume.

jAuriya Wrote:So I could use CoreAnimation for 2D image rendering as well then?

Oh yes, absolutely. I believe CoreAnimation on iPhone is very easy to learn compared to OpenGL, or even Quartz for that matter. You will have to carefully read the documentation (and be patient) for now since there aren't any "legal" tutorials available yet, but if you have some programming experience it shouldn't be impossible to learn how to do it with the resources Apple provides to iPhone developers. I can't say what or where to look, but it's all there. The learning curve with CoreAnimation can be measured in hours (assuming you know Obj-C and general Cocoa), rather than weeks with OpenGL (which will still require some Obj-C knowledge on iPhone to get going). It will be best to have some prior knowledge of Cocoa programming. Pretty much you will need to know that for iPhone development anyway. The only alternative to learning the iPhone OS environment would be Unity I believe, but I don't know the details of their iPhone program.