Hi all,
I have a projection matrix that I'm building manually...
Can anyone tell me how I can turn this to an orthographic view matrix? I keep trying examples online, but always get non-orthographic, sometimes hilarious, results.
(Note: For reasons of a tyrannical co-programmer, I can't simply use the Direct3DX functions to do this)
Thanks!
float aAspect = (float)gPageWidth/(float)gPageHeight;
float aNear = gZNear;
float aFar = GetZDepth();
float aWidth=COS(theFOV / 2.0f);
float aHeight=COS(theFOV / 2.0f);
if (aAspect > 1.0) aWidth /= aAspect;
else aHeight *= aAspect;
float s = SIN(theFOV / 2.0f);
float d = 1.0f - aNear/aFar;
float aMatrix[4][4];
aMatrix[0][0]=aWidth;
aMatrix[1][0]=0;
aMatrix[2][0]=0;
aMatrix[3][0]=0;
aMatrix[0][1]=0;
aMatrix[1][1]=aHeight;
aMatrix[2][1]=0;
aMatrix[3][1]=0;
aMatrix[0][2]=0;
aMatrix[1][2]=0;
aMatrix[2][2]=s/d;
aMatrix[3][2]=-(s * aNear / d);
aMatrix[0][3]=0;
aMatrix[1][3]=0;
aMatrix[2][3]=s;
aMatrix[3][3]=0;