typedef float mat4[16];
-void mat4_identity(mat4 mat);
-void mat4_ortho(mat4 mat,
+void mat4_identity(mat4 *mat);
+void mat4_ortho(mat4 *mat,
f32 left, f32 right,
f32 top, f32 bottom,
f32 near, f32 far);
-void mat4_proj(mat4 mat);
+void mat4_proj(mat4 *mat);
#endif //VECMATH_H
glUseProgram(program);
mat4 ortho_mat;
- mat4_ortho(ortho_mat, 0, 800, 0, 600, 0.0f, 100.0f);
+ mat4_ortho(&ortho_mat, 0, 800, 0, 800, 0.0f, 100.0f);
GLuint ortho_mat_loc = glGetUniformLocation(program, "u_proj");
glUniformMatrix4fv(ortho_mat_loc, 1, false, (f32 *) ortho_mat);
void
-mat4_identity(mat4 mat)
+mat4_identity(mat4 *mat)
{
- foreach(i, 0, 16) mat[i] = 0.0f;
- mat[0 * 4 + 0] = 1.0f;
- mat[1 * 4 + 1] = 1.0f;
- mat[2 * 4 + 2] = 1.0f;
- mat[3 * 4 + 3] = 1.0f;
+ foreach(i, 0, 16) (*mat)[i] = 0.0f;
+ (*mat)[0 * 4 + 0] = 1.0f;
+ (*mat)[1 * 4 + 1] = 1.0f;
+ (*mat)[2 * 4 + 2] = 1.0f;
+ (*mat)[3 * 4 + 3] = 1.0f;
}
void
-mat4_ortho(mat4 mat,
+mat4_ortho(mat4 *mat,
f32 left, f32 right,
f32 top, f32 bottom,
f32 near, f32 far)
{
- foreach(i, 0, 16) mat[i] = 0.0;
+ foreach(i, 0, 16) (*mat)[i] = 0.0;
- mat[0 * 4 + 0] = 2.0f / (right - left);
- mat[1 * 4 + 1] = 2.0f / (top - bottom);
- mat[2 * 4 + 2] = -2.0f / (far - near);
- mat[3 * 4 + 3] = 1.0f;
+ (*mat)[0 * 4 + 0] = 2.0f / (right - left);
+ (*mat)[1 * 4 + 1] = 2.0f / (top - bottom);
+ (*mat)[2 * 4 + 2] = -2.0f / (far - near);
+ (*mat)[3 * 4 + 3] = 1.0f;
- mat[3 * 4 + 0] = -(right + left) / (right - left);
- mat[3 * 4 + 1] = -(top + bottom) / (top - bottom);
- mat[3 * 4 + 2] = -(far + near) / (far - near);
+ (*mat)[3 * 4 + 0] = -(right + left) / (right - left);
+ (*mat)[3 * 4 + 1] = -(top + bottom) / (top - bottom);
+ (*mat)[3 * 4 + 2] = -(far + near) / (far - near);
}