Original Post
Hi. I''m learning DirectX 8 and I''m trying to create my own version of D3DXMatrixPerspectiveFovLH(). What I''ve got is this:
//Create a left-handed projection matrix.
matrix4 createProjectionMatrixLH(matrix4 &mOut,
float fovy,
float Aspect,
float znear,
float zfar)
{
ZeroMemory(&mOut, sizeof(matrix4));
if(sinf(fovy/2.0f))
{
float w = cosf(fovy/2.0f) / sinf(fovy/2.0f) * Aspect;
float h = cosf(fovy/2.0f) / sinf(fovy/2.0f);
float Q = zfar / (zfar - znear);
mOut._11 = w;
mOut._22 = h;
mOut._33 = Q;
mOut._34 = 1.0f;
mOut._43 = -Q * znear;
}
return mOut;
}
But the image it''s giving me is stretched horizontally. Also: I''m running it in windowed mode and before I could resize the client area without it distorting the image, now it does. The only time the image looks right is if I make the client area square. I''m still finding Aspect the same way as when I was using the D3DXMatrixPerspectiveFovLH() function; and the debugger is showing me what seems to be the correct value for Aspect... I don''t know what''s going on?
GrahamZ.