Closed Danielwbolson closed 5 years ago
Here is the fix - Rename near
to nearVal
or something similar. Same with far
to farVal
Matrix4 Matrix4::Perspective(float fovyInDegrees, float aspectRatio,
float nearVal, float farVal)
{
// https://www.khronos.org/opengl/wiki/GluPerspective_code
float ymax, xmax;
ymax = tanf(fovyInDegrees * M_PI / 360.0)* nearVal;
// ymin = -ymax;
// xmin = -ymax * aspectRatio;
xmax = ymax * aspectRatio;
return Matrix4::Frustum(-xmax, xmax, -ymax, ymax, nearVal, farVal);
}
Matrix4 Matrix4::Frustum(float left, float right,
float bottom, float top,
float nearVal, float farVal)
{
return Matrix4::FromRowMajorElements(
2.0* nearVal /(right-left), 0, (right+left)/(right-left), 0,
0, 2.0* nearVal /(top-bottom), (top+bottom)/(top-bottom), 0,
0, 0, -(farVal + nearVal)/(farVal - nearVal), -2.0* farVal * nearVal /(farVal - nearVal),
0, 0, -1, 0
);
}
I did something very similar in the pull request I opened. I'm not sure if val or plane is a more accurate variable name
Oh nice :). I didn't realize you already had the fixes.
Matrix uses near and far as input variables to the perspective function. Those overlap with macros from minwindef