Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make a quick demo program showing a cube, or a user loaded model, rotating in screen rendered with one of three projections: perspective, isometric and cavalier.

Using the fixed pipeline, how can I build a projection matrix for cavalier projection?

I think I can start with the orthographic projection matrix and then tweak the values, by eye, until I get the z of the vertices go to the right and up as farther the z is. I want the lines parallel to the z axis rendered as vertical lines 45 degrees rotated to the right.

share|improve this question
up vote 6 down vote accepted

For a cavalier projection, it looks like you would want to start with an orthographic projection and then apply a shear to the z-axis.

In other words, for OpenGL you would want to multiply the projection matrix on the left by a matrix of the form:

1 0 a 0
0 1 a 0
0 0 1 0
0 0 0 1

where a is the shear factor, which you'd tune to taste. (You could also use two separate shear factors along x and y, if you wanted an angle other than 45 degrees.)

share|improve this answer
I think this is what I'm after. Just let me do a quick test before mark as answer. – Hatoru Hansou May 12 '14 at 20:59
Marked as answer. Just note that OpenGL expects arrays representing matrices being in column-major order. – Hatoru Hansou May 13 '14 at 0:58
@HatoruHansou: That should not matter in this answer, it is not given in anything that resembles array notation. If there were commas in this, then that might imply something about the order of the elements in memory. This is just a generic matrix, you can figure out that it is supposed to be 1,0,0,0, 0,1,0,0, a,a,1,0, 0,0,0,1 from the API tags. – Andon M. Coleman May 13 '14 at 1:18
@HatoruHansou The property of the matrix that matters here is the side from which you multiply in the vectors. In the fixed function pipeline you have post-multiplication (Mv) which results in the a elements being in the third column. If you used pre-multiplication (vM), the a elements would be in the third row instead. Storage order and multiplication side are orthogonal concerns, their only relation is that messing up both at the same time tends to result in something that sometimes appears to be right. – Lars Viklund May 13 '14 at 2:08
I didn't take that matrix as an array. The answer is ok as it is but, believe me, someone may arrive here as result of a web search and simply add the commas, some will realize what just happened when running their programs, others may need to think for a while. OpenGL documentation contains warnings about the elements order because people tend to expect the opposite order, isn't it? – Hatoru Hansou May 13 '14 at 3:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.