Skip to content

Commit

Permalink
projection: fix extraction of far plane in orthographic view
Browse files Browse the repository at this point in the history
The equation for the far plane in othographic projections was wrong
(it's not the same as the one for perspective projections).
  • Loading branch information
mardy authored and WinterMute committed Jun 9, 2024
1 parent d3ab69e commit 9d78249
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/gc_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,16 @@ static void get_projection_info(u8 *type, float *near, float *far)

if (glparamstate.projection_matrix[3][3] == 0) {
*type = GX_PERSPECTIVE;
*near = B / (A - 1.0);
*near = B / (A - 1.0f);
if (A != -1.0f) {
*far = B / (A + 1.0f);
} else {
*far = 1.0f;
}
} else {
*type = GX_ORTHOGRAPHIC;
*near = (B + 1.0) / A;
}
if (A != -1.0) {
*far = B / (A + 1.0);
} else {
*far = 1.0;
*near = (B + 1.0f) / A;
*far = (B - 1.0f) / A;
}
}

Expand Down

0 comments on commit 9d78249

Please sign in to comment.