# Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 1.42 KB  |  hits: 13  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. Incorrect order of matrix values in glm?
2. glm::mat4 projection(1.0);
3. projection = glm::ortho( 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 500.0f);
4.
5. 0.00313   0.00000   0.00000   0.00000
6.  0.00000  -0.00417   0.00000   0.00000
7.  0.00000   0.00000  -0.00200   0.00000
8. -1.00000   1.00000  -1.00000   1.00000
9.
10. 0.00313   0.00000   0.00000  -1.00000
11.  0.00000  -0.00417   0.00000   1.00000
12.  0.00000   0.00000  -0.00200  -1.00000
13.  0.00000   0.00000   0.00000   1.00000
14.
15. template <typename valType>
16. inline detail::tmat4x4<valType> ortho(
17.     valType const & left,
18.     valType const & right,
19.     valType const & bottom,
20.     valType const & top,
21.     valType const & zNear,
22.     valType const & zFar)
23. {
24.     detail::tmat4x4<valType> Result(1);
25.     Result[0][0] = valType(2) / (right - left);
26.     Result[1][1] = valType(2) / (top - bottom);
27.     Result[2][2] = - valType(2) / (zFar - zNear);
28.     Result[3][0] = - (right + left) / (right - left);
29.     Result[3][1] = - (top + bottom) / (top - bottom);
30.     Result[3][2] = - (zFar + zNear) / (zFar - zNear);
31.     return Result;
32. }
33.
34. Result[0][3] = - (right + left) / (right - left);
35.     Result[1][3] = - (top + bottom) / (top - bottom);
36.     Result[2][3] = - (zFar + zNear) / (zFar - zNear);
37.
38. uniform mat4 uni_MVP;
39.
40. in  vec2 in_Position;
41.
42. void main(void)
43. {
44.   gl_Position = uni_MVP * vec4(in_Position.xy,0.0, 1.0);
45. }
46.
47. 0  4  8  12
48.  1  5  9  13
49.  2  6 10  14
50.  3  7 11  15
51.
52. 0  1  2  3
53.  4  5  6  7
54.  8  9 10 11
55. 12 13 14 15