orthographic projection for fov=0, rework of order and defaults for 3d camera api
This commit is contained in:
@ -52,3 +52,24 @@ Matrix4 camera_perspective(const Camera *const camera) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Matrix4 camera_orthographic(const Camera *const camera) {
|
||||
/* from cglm */
|
||||
(void)camera;
|
||||
|
||||
Matrix4 result = {0};
|
||||
|
||||
const float rl = 1.0f / (float)1;
|
||||
const float tb = 1.0f / (float)1;
|
||||
const float fn = -1.0f / (CAMERA_FAR_Z - CAMERA_NEAR_Z);
|
||||
|
||||
result.row[0].x = 2.0f * rl;
|
||||
result.row[1].y = 2.0f * tb;
|
||||
result.row[2].z = 2.0f * fn;
|
||||
result.row[3].x = -(float)1 * rl;
|
||||
result.row[3].y = -(float)1 * tb;
|
||||
result.row[3].z = (CAMERA_FAR_Z + CAMERA_NEAR_Z) * fn;
|
||||
result.row[3].w = 1.0f;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user