Wednesday, March 7, 2018

For 2D games, is there any reason NOT to use a 3D API like Direct3D or OpenGL?


I've been out of hobby Game Development for quite a while now. Back when I did it, most people used Direct Draw to create 2D games. By the time I stopped people were saying OpenGL or Direct3D with an orthogonal projection is just the way to go.


I'm thinking about getting back into creating 2D games, in particular on mobile phone but maybe on the XNA platform as well. To make something using OpenGL I'd have a (hopefullly) small learning curve to acclimate myself to 3D development.


Is there any reason to skip that and instead work with a 2D framework where I just have a Width x Height frame buffer I need to fill with pixels?



Answer



You should definitely be using something that uses a 3D renderer on the backend. But in your higher level code, you shouldn't even see the Z axis. All of that should be abstracted away at the lower levels. If you are manipulating pixels directly, you are probably doing something wrong.


For my own games, I built up a set of classes for dealing with 2D objects. My game logic was only dealing with x and y coordinates. My classes also handled things like rotation, scaling, blend modes, etc, etc.



Of course, there are also existing 2D libraries that you can use as well -- Cocos2D is a popular one on the iPhone. Most, if not all, of these libraries will be built upon the lower level 3D APIs so that they benefit from the acceleration available.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...