-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathprojection.cpp
More file actions
42 lines (34 loc) · 1.06 KB
/
projection.cpp
File metadata and controls
42 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <fea/rendering/projection.hpp>
#define GLM_FORCE_RADIANS
#include <glm/gtc/type_ptr.hpp>
namespace fea
{
glm::mat4x4 Projection::createOrthoProjection(GLfloat left, GLfloat right, GLfloat top, GLfloat bottom, GLfloat nearr, GLfloat farr) const
{
GLfloat r_l = right - left;
GLfloat t_b = top - bottom;
GLfloat f_n = farr - nearr;
GLfloat tx = -(right + left) / (right - left);
GLfloat ty = -(top + bottom) / (top - bottom);
GLfloat tz = -(farr + nearr) / (farr - nearr);
float matrix[16];
matrix[0] = 2.0f / r_l;
matrix[4] = 0.0f;
matrix[8] = 0.0f;
matrix[12] = tx;
matrix[1] = 0.0f;
matrix[5] = 2.0f / t_b;
matrix[9] = 0.0f;
matrix[13] = ty;
matrix[2] = 0.0f;
matrix[6] = 0.0f;
matrix[10] = 2.0f / f_n;
matrix[14] = tz;
matrix[3] = 0.0f;
matrix[7] = 0.0f;
matrix[11] = 0.0f;
matrix[15] = 1.0f;
glm::mat4x4 glmMat = glm::make_mat4(matrix);
return glmMat;
}
}