Skip to content

Commit 614e274

Browse files
committed
Update matrix_transform.hpp
fix
1 parent c9a2281 commit 614e274

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

glm/gtc/matrix_transform.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,25 @@ class matrix_transform : public constants<T>
9696
zero, zero, -(two * zFar * zNear) / d, zero);
9797
}
9898

99+
static GLM_API mat<4, 4, T> frustumZO(value_type left, value_type right, value_type bottom, value_type top, value_type zNear, value_type zFar)
100+
{
101+
T w = right - left;
102+
T h = top - bottom;
103+
T d = zFar - zNear;
104+
105+
return mat<4, 4, T>(
106+
(2.0f * zNear) / w, 0.0f, 0.0f, 0.0f,
107+
0.0f, (2.0f * zNear) / h, 0.0f, 0.0f,
108+
(right + left) / w, (top + bottom) / h, zFar / (zNear - zFar), -1.0f,
109+
0.0f, 0.0f, -(zFar * zNear) / d, 0.0f);
110+
}
111+
99112
static GLM_API mat<4, 4, T> perspective(T fovY, T aspect, T zNear, T zFar)
100113
{
101114
#if 0
102115
T h = tan(fovY * half) * zNear;
103116
T w = h * aspect;
104-
return frustum(-w, w, -h, h, zNear, zFar);
117+
return frustumZO(-w, w, -h, h, zNear, zFar);
105118
#else
106119
const T tanHalfFovy = tan(fovY * half);
107120
mat<4, 4, T> m(zero);

0 commit comments

Comments
 (0)