
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 1.42 KB | hits: 13 | expires: Never
Incorrect order of matrix values in glm?
glm::mat4 projection(1.0);
projection = glm::ortho( 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 500.0f);
0.00313 0.00000 0.00000 0.00000
0.00000 -0.00417 0.00000 0.00000
0.00000 0.00000 -0.00200 0.00000
-1.00000 1.00000 -1.00000 1.00000
0.00313 0.00000 0.00000 -1.00000
0.00000 -0.00417 0.00000 1.00000
0.00000 0.00000 -0.00200 -1.00000
0.00000 0.00000 0.00000 1.00000
template <typename valType>
inline detail::tmat4x4<valType> ortho(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & zNear,
valType const & zFar)
{
detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom);
Result[2][2] = - valType(2) / (zFar - zNear);
Result[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom);
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
return Result;
}
Result[0][3] = - (right + left) / (right - left);
Result[1][3] = - (top + bottom) / (top - bottom);
Result[2][3] = - (zFar + zNear) / (zFar - zNear);
uniform mat4 uni_MVP;
in vec2 in_Position;
void main(void)
{
gl_Position = uni_MVP * vec4(in_Position.xy,0.0, 1.0);
}
0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15