   openGL matrix question
  hi all , i'm well experimented with directx9 but in opengl things are different , i'm currently writting , a multiple Renderer System and i'm designing my matrix class.1) do opengl organise the matrix this way ?Rx Ry Rz TxUx Uy Uz TyDx Dy Dz Tz0  0  0  1 with R be X axis vector, U Up vector and D Direction Vector , T translation part.because D3D is like thisRx Ux Dx 0Ry Uy Dy 0Rz Uz Dz 0Tx Ty Tz 12) I'm having trouble with generating lookat matrix and perspective matrix :for perspective i set the matrix like this :zoomx 0 0    00zoomy  0    000 f+n/f-n   100 2nf/f-n   0with zoomx = zoomy/AspectRatio and zoomy = tan(fov/2)in wich order should i load this matrix to the projection stack ? row order or column order ? , i can't have a correct display...The lookat matrix is this:RxUx  DxRyUy  DyRzUz  Dz-dot(Eye,R)  -dot(Eye,U) -dot(Eye,D)R X axis of the cameraU Up vectorD Direction vector (at-eye)How to load these matrices in opengl stack ? Row or Column major ?please helpthanx in advance.   
Quote:Original post by ninihi all , i'm well experimented with directx9 but in opengl things are different , i'm currently writting , a multiple Renderer System and i'm designing my matrix class.1) do opengl organise the matrix this way ?Rx Ry Rz TxUx Uy Uz TyDx Dy Dz Tz0  0  0  1 with R be X axis vector, U Up vector and D Direction Vector , T translation part.because D3D is like thisRx Ux Dx 0Ry Uy Dy 0Rz Uz Dz 0Tx Ty Tz 1In your examples you seem to have the basis vectors of the linear transform part transposed; unless those are intended to be view matrices (or something), the upper-left 3x3 portions are incorrect.Quote:2) I'm having trouble with generating lookat matrix and perspective matrix :for perspective i set the matrix like this :zoomx 0 0    00zoomy  0    000 f+n/f-n   100 2nf/f-n   0with zoomx = zoomy/AspectRatio and zoomy = tan(fov/2)OpenGL projection matrices differ from (the left-handed versions of) DirectX projection matrices in terms of handedness (which affects the signs of certain elements) and z-clipping range (which affects the values of certain elements). Check out the Red Book for how OpenGL-style projection matrices are constructed.Quote:in wich order should i load this matrix to the projection stack ? row order or column order ? , i can't have a correct display...The lookat matrix is this:RxUx  DxRyUy  DyRzUz  Dz-dot(Eye,R)  -dot(Eye,U) -dot(Eye,D)R X axis of the cameraU Up vectorD Direction vector (at-eye)How to load these matrices in opengl stack ? Row or Column major ?please helpthanx in advance.The lookat matrix needs to be transposed and adjusted for right-handedness; check out the DirectX right-handed look-at function for an example. You might be running into other problems as well that aren't evident from your post; for example, with matching vector and layout conventions, OpenGL and DirectX matrices are actually arranged identically in memory, but with unmatched conventions additional transposes may be required.In short though, OpenGL matrices are expected to be column-major, and OpenGL is typically thought of as using column-vector notation. (In any case, the basis vectors are expected to be contiguous in memory.)   