| 167 | } |
| 168 | |
| 169 | Mat4 Ortho(float l, float r, float b, float t, float n, float f) |
| 170 | { |
| 171 | Mat4 m; |
| 172 | float rl = (r - l != 0.0f) ? (r - l) : 1e-6f; |
| 173 | float tb = (t - b != 0.0f) ? (t - b) : 1e-6f; |
| 174 | float fn = (f - n != 0.0f) ? (f - n) : 1e-6f; |
| 175 | m.at(0, 0) = 2.0f / rl; |
| 176 | m.at(1, 1) = 2.0f / tb; |
| 177 | m.at(2, 2) = -1.0f / fn; // zero-to-one depth: near plane -> 0, far plane -> 1 |
| 178 | m.at(0, 3) = -(r + l) / rl; |
| 179 | m.at(1, 3) = -(t + b) / tb; |
| 180 | m.at(2, 3) = -n / fn; |
| 181 | m.at(3, 3) = 1.0f; |
| 182 | return m; |
| 183 | } |
| 184 | |
| 185 | Mat4 Perspective(float fovYRadians, float aspect, float n, float f) |
| 186 | { |
no test coverage detected