add zoom option to camera to work around the orthographic camera

This commit is contained in:
veclavtalica
2025-01-27 03:25:14 +03:00
parent 791ab628ca
commit 6a87119c70
5 changed files with 24 additions and 10 deletions

View File

@ -59,15 +59,15 @@ Matrix4 camera_orthographic(const Camera *const camera) {
Matrix4 result = {0};
const float rl = 1.0f / (float)1;
const float tb = 1.0f / (float)1;
const float rl = 1.0f / (camera->viewbox[0].y - camera->viewbox[0].x);
const float tb = 1.0f / (camera->viewbox[1].x - camera->viewbox[1].y);
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].x = -(camera->viewbox[0].y + camera->viewbox[0].x) * rl;
result.row[3].y = -(camera->viewbox[1].x + camera->viewbox[1].y) * tb;
result.row[3].z = (CAMERA_FAR_Z + CAMERA_NEAR_Z) * fn;
result.row[3].w = 1.0f;