user3704920
user3704920

Reputation: 615

What Does orthoM() Do Under the Hood?

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?

Upvotes: 0

Views: 287

Answers (1)

Tommy
Tommy

Reputation: 100622

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.

Upvotes: 1

Related Questions