Open nyanzebra opened 9 years ago
There seems to be a missing assignment for the last element in the matrix.
mat4 mat4::perspective(float fov, float aspectRatio, float near, float far) { mat4 result(1.0f); float q = 1.0f / tan(toRadians(0.5f * fov)); float a = q / aspectRatio; float b = (near + far) / (near - far); float c = (2.0f * near * far) / (near - far); result.elements[0 + 0 * 4] = a; result.elements[1 + 1 * 4] = q; result.elements[2 + 2 * 4] = b; result.elements[3 + 2 * 4] = -1.0f; result.elements[2 + 3 * 4] = c; return result; }
I believe the 15th element should be 0. source = http://www.songho.ca/opengl/gl_projectionmatrix.html
So, fix would be adding
result.elements[3+3*4]=0;
This should be fixed. I had a problem trying to setup a true first person camera but it kept on looking like a third person camera. By adding that line, the problem was fixed.
Make a pull request
There seems to be a missing assignment for the last element in the matrix.
I believe the 15th element should be 0. source = http://www.songho.ca/opengl/gl_projectionmatrix.html
So, fix would be adding