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

Apprentice
Posts: 13
Joined: 2008.06
Post: #1
Hello everyone!

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. Rasp )
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #3
Thank you for the quick reply!

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
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #4
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).
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #5
What Cochrane said: getting into OpenGL on the ES end will most probably make you a better graphics programmer than either vanilla GL and Quartz. Smile

(och välkommen!)
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #6
Hey!

Whoa nice resources and help here, thank you all! ^^

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! Rasp )

Anyway thanks for the answers, greatly appreciated!

Greets/Tack,
~J
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #7
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.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #8
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.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #9
For some tutorials, check out http://iphonedevcentral.org/ (am I allowed to post this?)
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #10
bronxbomber92 Wrote:For some tutorials, check out http://iphonedevcentral.org/ (am I allowed to post this?)

Hey thanks for this!
I'll look into it now. ^^


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;

<Main Game Loop>
<Check For Events & Inputs>
<IfEvents -> DoGameHandling>
<Check FPS, update Timer(s) and update Screen>
</Main Game Loop>

So when there are no events going on, it does nothing but handle the FPS, Timers and updating the screen.

This is the best way I have experienced games on laptops (using a Macbook right now), least CPU usage and so longer battery life while gaming. I believe this would also apply for the iPhone.

So I could use CoreAnimation for 2D image rendering as well then?
Sorry if I sound a bit too, -- not knowing, I'd rather have it right than be confused or do things over many times. Wink

Thank you all very much for the help so far!
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #11
@ bronxbomber92: Never heard of them, but:

"Experience developing on the MAC applications"

Wacko ... 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.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #12
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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #13
AnotherJake Wrote:...since there aren't any "legal" tutorials available yet

Sure there are.

Download the Free iPhone SDK and start reading the documentation and sample code.

Or just read the Core Animation documentation from the desktop.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #14
LOL Touché!
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2008.06
Post: #15
Thats so great! This topic has helped me a lot!
Awesomely iThanks to everyone here! ^^ Thanks for all the information!

I hope to also help out someday when I progress far enough! Grin

Cheers,
~J
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  what iPhone device versions to target for physics based games? mixedup 3 1,646 Sep 30, 2013 01:22 PM
Last Post: mawigator
  Music bitrate for ipad and iphone games Bambinou 5 9,974 Nov 19, 2011 07:02 PM
Last Post: fugufish
  OpenGL Differences between iPhone Sim and Real iPhone SparkyNZ 5 6,895 Apr 13, 2011 11:40 AM
Last Post: SparkyNZ
  iPhone 4 and 480x320 games bmantzey 15 13,467 Sep 30, 2010 11:18 PM
Last Post: monteboyd
  Why bluetooth games do not work on iPhone 2G? riruilo 13 9,036 Mar 31, 2010 07:53 AM
Last Post: alibaba123