When to use OpenGL?

Posts: 3
Joined: 2011.07
Post: #1
Im looking at developing a game that involves a man running around trying to avoid hitting objects. I was told by a dev shop that for anything fast moving or 3D I need to use OpenGL, which they claim to be complex and therefore costly to setup and get going in. We discussed some other options, but everything appeared to point back to needing to use OpenGL.

What is the general rule regarding what to use for developing an iOS game? When should Cocoa2D or other libraries be used over OpenGL and is OpenGL truly that heavy and complex to develop in?


Quote this message in a reply
Posts: 65
Joined: 2009.03
Post: #2
Hi J

The first thing to note is that Cocos2D actually uses OpenGL under the hood. It provides an Objective-C wrapper that allows you to think in terms of Nodes and Sprites etc while underneath all the rendering is being done using OpenGL.

What you have been told is also correct. If you want to have many objects on screen moving around, you'll quickly reach the limits of using views etc but it really depends on the project you have in mind. If you wanted to do a simple breakout clone or asteroids then you could do those using Cocoa and views or CA layers. If however you want to have special effects, particle systems, lighting etc then you will need to move to OpenGL.

Cocos2D is a great library for creating games and has been used by hundreds of games on the App Store. It has a steepish learning curve but it does protect you from the ever steeper OpenGL learning curve.

That said, I always believe it's handy to understand the basics of what is happening under the hood so you can get the most out of the engine you decide to use.

Bit of a ramble there, but using OpenGL or not really does depend on your specific needs, but my advice would be that you'll end up needing it sooner or later so you may as well start out that way.

Hope that helps.


iPhone Game Development Blog - 71Squared
Quote this message in a reply
Posts: 1,487
Joined: 2002.09
Post: #3
This thread from yesterday is relevant: http://www.idevgames.com/forums/thread-9183.html

First of all, for a 2D game and an experienced developer, Cocos2D vs. Cocos2D is a non-question. OpenGL isn't terribly hard to learn. Buy a book on OpenGL and you'll have sprites on the screen in a couple days. Making a sprite batch renderer is a few dozen lines of OpenGL code, and a couple dozen more for loading textures. If your dev is telling you that making a 2D game with OpenGL is hard... you might be talking to the wrong people.

Cocos2D's biggest strength IMO is that it makes it really easy to get an image on the screen in just a couple lines of code. The problem with it is that it imposes a lot of restrictions on what you can do and how you can do it that a lot of experienced developers will find very frustrating. Especially when they know how to write a 2D rendered tailored to their needs without a lot of effort. I guess I would disagree with MikeD one one point and say that Cocos2D has a very long, but easy learning curve. OpenGL has a fairly steep, but short one. For 2D games, you don't have to learn that much of OpenGL though.

3D is another beast. Simple 3D games can be easy too (no animated meshes, simple lighting, simple "shaders"), but can quickly spiral into madness if you want a 3D game that does anything fancy (animated meshes, fancy shaders, fancy lighting, lightmapping, etc, etc, etc,). If you are writing your own 3D engine, you are either: making something simple, making it to learn, have the experience to do it right, or wasting time.

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
Post Reply