When I use each of them with the same parameters the only difference I notice is how close the 'camera' is from the objects. What is the difference here, and which is preferred for a mainly 2D game?
-
http://stackoverflow.com/questions/2571402/explain-the-usage-of-glortho/36046924#36046924 – Ciro Santilli OurBigBook.com Mar 16 '16 at 21:06
3 Answers
I don't agree with LeffelMania, although his answer is already accepted, I would like to explain again what a frustum is and what the differences between orthographic and perspective projections are.
A frustum is a pyramid without the top shaped 3D object (in the link defined by the space between the zNear and zFar plane).
The frustum is used to determine what the camera can see. Everything that is inside or intersects with the camera's view-frustum has to be rendered, all the rest can be ignored.
Because a frustum is a difficult shape to do intersection checks on, often a matrix transform is constructed so that the view frustum is transformed to a cube. This matrix transform is also applied to all scene objects so that we can now do a simple 'does it intersect with a cube' check. This is called the canonical view frustum (see more info here)
Now about perspective vs orthographic projection. In the picture you see the camera, or center of projection (COP). In a perspective projection the COP is near the near plane. Rays from all positions on the far plane are pointing at the COP. Where these rays intersect the near plane (aka viewport) a pixel is colored according to the color of the closest thing to the near plane that the ray hit. A perspective projection leads to (multiple) vanishing points and objects further away from the camera are smaller, also parallel lines in the world are not necessarily parallel on the picture.
In an orthographic projection the COP is infinitely far away, so the rays are almost parallel to each other. There is no vanishing point, more distant objects are not drawn smaller and parallel lines in the world are parallel on the picture.

- 9,429
- 2
- 48
- 70
-
Apparently "Generally speaking" and "gross generalization" didn't qualify my answer well enough. We completely agree, you just used a lot more words and a picture... – LeffelMania Apr 29 '11 at 22:15
-
7Sorry but "is used for 3D scenes to accommodate a perspective view projection" is so vague that I just had to fill in more details. "it accounts for each object's distance ... (and) viewing angle" is a weird statement, since the view frustum itself has no knowledge of this at all and is not used for any distance or angle computation. All the view frustum is, is a way to cull a scene. – Roy T. Apr 30 '11 at 07:47
Generally speaking a Frustum is used for 3D scenes to accommodate a Perspective view projection. It accounts for each object's distance from the camera as well as viewing angle to determine an object's size and position on the screen. An orthographic projection simply takes each object and draws a straight line from the object to a pixel on the screen, making it just a flat scene. That's a gross generalization and there's a lot to be said on the subject, but for a 2D game you'll want to use an orthographic projection.

- 12,765
- 4
- 32
- 34
There was two type of projection corresponding to what you mentioned:
Orthographic Projection and the Perspective Projection.
Graphs below to help you quickly understand the difference between the two:
Orthographic Projection
Perspective Projection

- 43
- 4