Are most games on the IPhone done with OpenGL ES? - iphone

I was just wondering if most games on the iPhone are done in OpenGL ES as opposed to using Quartz and Core Animation. Are Quartz and Core Animation mostly used for just creating slick interfaces? Or if there is a point with games where OpenGL probably has to be used over using other tools?

For efficiency reasons OpenGL ES is you best choice for games, unless your writing a "simple" board game or card game (like Solitaire). In this case Core Animation would be a good fit.

You should check out cocos2d-iphone if you are going to do a 2d game. It seems to be a pretty solid foundation. It comes with the chipmunk physics engine and everything all ready to go.

I think OpenGL is your best choice, I can't agree that the Quartz stuff is any easier to use.
Also if you're successful then most of your code will be portable to other platforms. Something to consider.

Mostly it comes down to whether you need 3D or not. If your game is entirely 2 dimensional, then using Quartz for your drawing is probably simpler. Not that OpenGL is all that complicated, but it is more complex than the Quartz interface.
Quartz drawing and compositing will be OpenGL accelerated when possible, so there shouldn't be much performance difference if you're strictly doing 2D drawing.

Related

iPhone. Benefits to using Open GL ES over Core Graphics in a live multiplayer game?

I am working on a live multiplayer version of a pictionary like game. It will be like draw something except live with 4 players and not turn based.
is there a benefit to writing my drawing algorythm in OpenGL ES vs CoreGraphics (Quatz 2D) in this situation since i have to be sharing it among 4 players over a network? Or as far as performance goes?
From my own experience in game development... the main reason is performance. Simple 2D game was VERY slow with core graphics and VERY fast with OpenGL ES (1.1).
There was a lot of issues with the positioning of images, strange lines between tiles but at the end we managed to fix it all. In reality, we built a small library of functions very similar to core graphics, only simpler and faster.
Also, portability with OpenGL is simple, with Core Graphics impossible.
CoreGraphics only works on apple products. OpenGL could maybe be adapted to different platforms. I would say that also performances should be better.
Core graphics is not designed for fast, real time drawing or updates to screen. It is designed for high quality artwork, while OpenGL is designed for fast performance, though getting high-quality visuals can be a bit more challenging with OpenGL. It's a trade-off between these of performance and quality of rendered visuals.

Which Path should i take when making a 2D iPhone game?

I have been looking into Open GL ES, Quartz 2D, a framework called cocos2D and I am not sure what would be the best direction to move forward in when making a 2D game. I am planning on making a pretty simple not to intense game and I am new to game development but not to iphone development.
Which would be the easiest to learn? Which one would give the best performance ?
Thanks
I was in the same position as you and I chose Cocos2D. It's perfect for a beginner. It's basically a wrapper for OpenGL ES, and it's open-source so you can see how it works and modify it to your liking.
Starting with Cocos2D is a good idea because you can make a lot of abstraction from complex low-level functionality, while achieving a good high-level overview of your game. While developing, you will pick up some low-level details as well, so that you'll be more prepared for them in future games.
Plus, Cocos2D has a really nice structure for simple 2D games. If you were to write this yourself in say OpenGL ES, then you would just lose a lot of time that you could be spending actually designing your game :)
But that's just my opinion.
Oh and don't worry too much about performance. Cocos2D is fine in that aspect. Like I said, it works on top of OpenGL ES so the drawing is done very efficiently. It also supports stuff like sprite batching and texture atlasses, which is good for performance.
As the goal of these frameworks is to provide simplified game development, this is definitely the way to go. Of those that you list, two of them are graphics "engines" (Open GL ES, Quartz 2D), and one is a game engine (cocos2D). If you choose graphics, then you'll probably have to write quite a bit of extra code, even for a simple game.

Is there a good rule of thumb to help decide when it is appropriate to use Quartz 2D v. Core Animation v. OpenGL in an iPhone/iPad app?

I'm looking for is a heuristic for determining which of the primary graphics methods for iPhone/iPad development would be the most appropriate solution for a given problem.
Simple answer:
Quartz 2D
Use Quartz 2D for custom interface elements to give a stylized look to your application.
Core Animation
Easier to use, although used where performance is not critical. Great for quick animation routines. a lot easier to do effect in. Used with UIViews as well. Can be used to create simple fine games. like pong or card games.
OpenGL ES
Great for performance critical games. A bit more complex but once you can get your head around the tutorials available and the frameworks provided you can create high perfomance games. And also port them to other devices other than the iphone very easily which is quite cool.
Long Answer:
Quartz 2D
Quartz 2D is the powerful 2D graphics API for iOS. It offers professional-strength 2D graphics features such as Bézier curves, transformations, and gradients. Use Quartz 2D for custom interface elements to give a stylized look to your application.
Core Animation
Core Animation is likely the appropriate choice for games where performance is not critical such as simon says type games, card games, and trivia games. Some might argue that OpenGL ES is easier to use, and it likely is if you’ve studied say.. DirectX.. but Core Animation (and Quartz 2D for that matter) is much easier to do simple effects in, and can be used with existing UIViews.
Core Animation is fine for games where performance is not critical, and for new programmers will likely be easy to use, OpenGL is needed for anything else.
Core Animation utilizes OpenGL ES, it is high level, and in my testing works fine in situations where performance is critical.
OpenGL ES
is your choice for performance critical games. Which is essentially anything but simple mostly static games like the ones mentioned I above such as first person shooters, flight simulators and the like. You also get the added benefit of potentially being able to port your games to a device other than the iPhone, and there is alot of existing game code in OpenGL that can be converted the other way. OpenGL ES is an open standard that is used on a growing number of devices created by a wide variety of companies, and because CoreAnimation is a higher level framework built atop OpenGL ES it cannot provide nearly the same performance.
http://maniacdev.com/2009/07/iphone-game-programming-coreanimation-vs-opengl-es/
http://developer.apple.com/technologies/ios/graphics-and-animation.html
PK

Core Animation or OpenGL for simple iPhone game

I am writing a simple game that animates a ball image quickly across a background image.
Would Core Animation/Quartz be sufficient for this scenario?
I don't really want to learn OpenGL ES if it is not going to provide any substantial benefit in this one off project.
This is a commonly asked question. Other questions like this include:
"iPhone board game: OpenGL ES or CoreGraphics?"
"Are most games on the IPhone done with OpenGL ES?"
"Core Animation or OpenGL ES?"
"Does openGL ES have a better performance than Core Animation and UIKit when it comes to highly animated user interfaces?"
OpenGL ES I suppose isnt too hard.
But at the end of the day Core Animation is going to be fine, its super powerful and not to hard to work with. It will also get you up and running so quick that you will release you game "sucks" a bit and you want to change it and you didn't even have to learn OpenGL.
I highly recommend looking at cocos2d. A very simple game engine for 2d stuff.
http://cocos2d.org/
Have a look at that.
Cheers, John
OpenGL ES isn't that hard, there are lot of really good resources in the web and step by step tutorials. Can be hard at first, but once you get the grip of It things will be easy. 71 Squared has very detailed tutorials:
http://www.71squared.co.uk/iphone-tutorials/
About the question, Core Animation Is great for most apps, but in a videogame It's fundamental to draw your game efficiently and have as much control as possible.
Cocos2d Is great and I recommend It If you need to write a good game, but if you're doing It for educational purposes I recommend OpenGL, You will learn a lot with It and gain a lot of experience.
Just jump to something like Cocos2D so that the OpenGL is done for you. OpenGL ES is significantly faster and more adaptable than Quartz, plus it's not any harder. I even think Quartz is a big pain in the butt and difficult to figure out, although I came from an OpenGL background on desktop computers first, so naturally that jump is pretty small. The point is, though, that either with Quartz or with OpenGL ES you're going to need to spend a lot of time with resource management, etc., so you might as well go with Cocos2D.
yes, it will be fine, as long as you're not wanting to do hundreds of balls at once or something else complicated like that.
If your knowledge of Core Animation is good then i recommend you to skip learning OpenGL ES for now, since it won't really help you (if all you want is what you described of course). On the other hand, if you plan to make more games which have more involved graphics, it might be a better idea to start learning the API. OpenGL ES is a simple API and you can use the full graphics features of the iPhone with it.
If all you want to do is just make this game, then i say go with what you know and are productive.
I would say this very much depends on what you want to do with the ball. If you simply want to fire off an animation and forget about it Core Animation will probably be fine. However, if you are trying to interact with the ball, for example by changing the direction of the ball mid-flight based on user interaction, then you probably want to consider OpenGL ES. Of course, you're other option is to use neither Core Animation or OpenGL ES and simply redraw your view on a timer.
If you're a fairly competent C programmer I wouldn't be too put off the OpenGL ES stuff. Apple supply a lot of the framework for hosting OpenGL ES views in their templates. Although OpenGL can get fairly involved, if you're not trying to render huge multi-object 3D scenes then the basics are fairly straightforward and you should be able to get some nice results quite easily. Although it is for OpenGL rather than OpenGL ES, I would recommend this set of video demos as a good starting point:
www.videotutorialsrock.com

Is OpenGL required for my iPhone game?

On an iPhone:
If I am writing a game that has multiple levels, with multiple animations (image sequences), jpg and png (transparent), some full screen and some not, some looped and some played once only. What is the best way of doing it? Each level might have up to 10MB of images. Add on to this music, and video (cut scenes). All 2D graphics, no 3D models.
Is OpenGL required? Or can this be achieved with Quartz or Core Animation?
I do similar using UIViews and a bit of Core Graphics (Quartz 2D) and it works fine. I've found the custom drawing in Core Graphics pushes it a bit further, tho - UIViews work best when given images rather than having to draw themselves. Also watch out for lots of transparencies. You'll probably find that large or long (many frame) animations will be the killer, though. There are some techniques for minimising the impact of the animations which involves allowing it to purge images from memory if not being immediately displayed (I forget the setting). This may result in your animations not being as smooth as you they would otherwise be (not sure if Open GL ES would help here, though).
You should probably prototype using UIViews, and decide then if it's worth doing the extra work for OpenGL ES. Also, if you're not already familiar with OpenGL/ Open GL ES it's a steep learning curve.
I've used both Quartz and OpenGL to do graphics on the iPhone, and while OpenGL has a much higher learning curve, it gives much better performance than Quartz. Let's say you have a scene that involves drawing 6 large, semi-transparent images on top of each other. Quartz will do it, but you'll probably get 15fps at best. OpenGL takes advantage of the iPhone's PowerVR chip and the drawing is hardware accelerated - so you can load those images into OpenGL textures and render at 25-30fps no problem.
I would agree with Phil though - try doing it using Quartz and see if it meets your needs. OpenGL is extremely powerful but it's API lacks some of the convenience features of Quartz (such as saving/restoring graphics state).
One another note entirely, you might want to take a look at Unity's iPhone development tools (http://unity3d.com/#iphone). They leverage OpenGL but provide you with an IDE to create your game. It abstracts away all of the graphics-level code, so you can focus on the high-level gameplay. My brother uses it to write iPhone games, and it's extremely cool.
I recommend having a look at Cocos2D iPhone.
cocos2d for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications. It is based on the cocos2d design: it uses the same API, but instead of using python it uses objective-c.
Most likely OpenGl.
One advantage of using OpenGL ES would be that the investment of time for learning the technology could be applied to other platforms/contexts and your game is potentially more port-friendly. These may not be important to you.
I would suggest using Quartz. OpenGL ES is really best for 3d stuff. However both work fairly well, so if you already know OpenGL ES, it's fine to use that.
You should consider using a lot of less resources in your game, Apple recommends not to use more than 10 mb in texture for openGL apps.
Try texture atlas, reuse graphics, tile based graphics...but avoid to use to much graphic assets.