direct x creating projection matrix
I want to create a projection matrix without using D3dx. This is the code I have so far:
They are both Left Handed matrices.
This is the formula d3dx uses to create a projection matrix:
void Engine::CameraSetProjection(float fov, float aspect, float znear, float zfar)
float yscale = cos(fov)/sin(fov);
float xscale = aspect/yscale;
mat._11 = xscale;
mat._22 = yscale;
mat._33 = zfar/(zfar-znear);
mat._34 = 1;
mat._43 = -znear*zfar/(zfar-znear);
How ever, that doesn't seem to be working. I am not seeing the triangles that I did when I used d3dx (I don't see any triangles). And the paramters stayed the same.
xScale 0 0 0
0 yScale 0 0
0 0 zf/(zf-zn) 1
0 0 -zn*zf/(zf-zn) 0
yScale = cot(fovY/2)
xScale = aspect ratio / yScale
I belive my error is in the cot function, I read cot = cos/sin. I also tried cot = 1/tan but neither seem to work.