# Open GL perspective projection vs orthographic projection

I am trying to build an engine using OpenGL however I have a question about the kind of projection to use.

1. For a 2D game should I use a perspective projection or an orthographic projection?

2. If I wanted to have the ability to use 3d in a 2d oriented game, which one should I use?

• Your chosen projection matrix has no effect on whether or not the graphics framework will support 2D or 3D. Also, projection matrices are trivial to change out, so why not just give them both a try?
– Evan
Jun 4, 2014 at 14:44

Using orthographic projection means everything will be projected to a 2D plane and objects will not be affected by the distance and/or angle from which you see them. Look at the image and you'll understand:

The two objects are exactly the same, but they are projected differently. Notice how distance affects what you see if you're using perspective projection. That gives the 3D touch to the engine. You don't need that in a 2D game.

If you don't want to include 3D in your engine you should be using an orthographic projection and an eye point (the point from which you are looking at the environment) above the ground.

• Thats great thanks. I have another question. If I use a perspective projection, how are you supposed to size your objects? For example I have a sprite that is 16x16 (pixels), how are you supposed to convert that into OpenGL coords (-1, 1)?
– Nick
Jun 4, 2014 at 15:59
• I just mentioned perspective projection because you asked about it, but in a 2D engine you really don't need it. It must operate on the z-axis, which you don't have when working in 2D. Jun 4, 2014 at 16:55
• Yeah I realize that, but what if I wanted to include some 3D stuff.
– Nick
Jun 4, 2014 at 17:24
• At the minute i have this imgur.com/1WCFxVM It is running a perspective projection displaying a 3d model and a sprite. The problem is that i have to specify the coords as: -1,1,0 etc which makes it kind of hard to position stuff. How do people deal with this?
– Nick
Jun 4, 2014 at 17:32
• If you want to have both 2D and 3D stuff, then you'll need to draw the 2D and 3D objects separately. You should also use a perspective projection for 3D. I never used OpenGl, but as for rendering sprites, I don't think they need any kind of projection since they have only 2 coordinates that can transformed into screen coordinates in a straightforward manner. Jun 5, 2014 at 12:54