30 lines
601 B
C++
30 lines
601 B
C++
#pragma once
|
|
|
|
namespace math {
|
|
|
|
inline void ortho_proj(float* mat, float left, float right, float bottom, float top,
|
|
float near, float far) {
|
|
|
|
mat[0] = 2.0f / (right - left);
|
|
mat[4] = 0.0f;
|
|
mat[8] = 0.0f;
|
|
mat[12] = -(right + left) / (right - left);
|
|
|
|
mat[1] = 0.0f;
|
|
mat[5] = 2.0f / (top - bottom);
|
|
mat[9] = 0.0f;
|
|
mat[13] = -(top + bottom) / (top - bottom);
|
|
|
|
mat[2] = 0.0f;
|
|
mat[6] = 0.0f;
|
|
mat[10] = -2.0f / (far - near);
|
|
mat[14] = -(far + near) / (far - near);
|
|
|
|
mat[3] = 0.0f;
|
|
mat[7] = 0.0f;
|
|
mat[11] = 0.0f;
|
|
mat[15] = 1.0f;
|
|
}
|
|
|
|
} /* namespace math */
|