   directx matrices
  in my app i need to set the projection matrix myself (meaning i CAN'T use D3DXMatrixPerspectiveFovLH)i went to the documentation that comes with directx and read about D3DXMatrixPerspectiveFovLH and this is what they say: xScale0000   yScale  0000  zf/(zf-zn)    100  -zn*zf/(zf-zn)0where:yScale = cot(fovY/2)xScale = aspect ratio / yScalewhen i use it it seems to be completely wrong!i can only make it work this way:Change #1:  i do xScale = yScale / aspect ratio (and not the other way as they say)Change #2: i negate xScale.that's the only way i get visual output, but i get it ofcourse mirrored on the x axis ...can anyone here please help me on this ?   
  cot(x) = 1 / tan(x). Do you do it that way ?I ask because the first time I read this I thought cot(x) was a typo and that it was cos(x).I also found this one :h = cos(fov/2) / sin(fov/2);w = h / aspect;2*zn/w  0  0    00  2*zn/h  0    00  0  zf/(zf-zn)10  0  zn*zf/(zn-zf)  0;  like you, for cot i used cos/sin.i'll try the projection matrix you offered, i hope it will work ;)thanks :)   ;  The matrix you got from D3DXMatrixPerspectiveFovLH looks correct. Make sure you are doing the multiplying correctly. It seems that for some reason your code works when you multiply by the inverse (or something like that) of the projection matrix.BTW, why can't you use D3DXMatrixPerspectiveFovLH?   ;  The reason i need to use the directx matrix is that my engine supports both directx and opengl, being that way the engine is an abstraction above both of those graphcis apis, so i want both outputs to be perfectly identical so i want to completely control what happens inside all the projection/modelview etc...   ;  Are you aware that GL and D3D utilize different matrix representations, and if so are you correctly compensating?   ;  The projection matrices for OpenGL and DirectX are different because the locations of the clip space planes are different.   ;Quote:Original post by RavyneAre you aware that GL and D3D utilize different matrix representations, and if so are you correctly compensating?i'm aware that it's left handed verses right handed, and i negate the z value of coordniates, but nothing more.am i missing something ?   ;  Yes, AFAIK OpenGL matrices are in column-major form, where the translation components tx, ty, tz occupy elements 13, 14 and 15 of the matrix (with respect to a 16 element, single-dimentional array containing the matrix).DirectX, on the other hand, uses row-major form, where the translation components tx, ty, tz occupy elements 4, 8 and 12 of the matrix. D3D matrices are the transpose of equivilant GL matrices.| 01 02 03 04 || 05 06 07 08 || 09 10 11 12 || 13 14 15 16 |   ;  Also note that the screen-space z-axis bounds are different between OpenGL and DirectX (as indicated by JohnBolton)In DirectX the near-plane is z = 0 and the far-plane is z = 1In OpenGL the near-plane is z = -1 and the far-plane is z = 1I can't remember the exact changes you have to make to the projection matrix to account for this but they're fairly simple (a sign change and a multiplication if I remember correctly).   