0

I've read the documentation and it says it creates an orthographic projection matrix. However, what does the matrix it uses for calculations look like?

I input values into the method:

0, 105.0, 495.0, 190.0, 410.0, 0, 1

and it outputs:

0.0051282053, 0.0, 0.0, 0.0, 
0.0, 0.009090909, 0.0, 0.0, 
0.0, 0.0, -2.0, 0.0, 
-1.5384616, -2.7272727, -1.0, 1.0

What would the resulting matrix look like when drawn?

user3704920
  • 617
  • 1
  • 8
  • 19

1 Answers1

1

orthoM inherits its API from glOrtho, which is documented on the relevant man page; based on a quick Googling, Microsoft's reproduction seemed to preserve the proper formatting.

So:

2 / (right - left)        0                         0                       tx
0                         2 / (top - bottom)        0                       ty
0                         0                         2 / (far - near)        tz
0                         0                         0                       1

... where tx = - (right + left) / (right - left), ty = - (top + bottom) / (top - bottom) and tz = - (far + near) / (far - near).

The value you've printed is that matrix transposed, because OpenGL is column major.

Tommy
  • 99,986
  • 12
  • 185
  • 204