Thanks again everyone.
Porting is coming along very nice and I'm happy with the results so far, as the OpenGL version runs faster than D3D, probably due to badly written D3D code on my side or the simplicity of GLSL shaders I use for now. Anyway I have another question.
I have entities which transformation is a D3DXMATRIX and I want to use that matrix for my OpenGL version of the renderer.
I did this already with my D3D view matrix, which is a D3DXMATRIX by multiplying it with a (1,1,-1) scaled matrix
I load this into OpenGL and it works as a MODEL_VIEW matrix which has the MODEL part identity, so all my meshes lie in origin with no scaling and rotation factors, but I can move the camera around correctly.D3DXMatrixScaling(&sca,1,1,-1) ; OGLMatrix = g_Camera->view * sca ;
Now I need to involve the meshes transform matrices from D3D so they are placed, scaled and rotated in the world, but I'm missing something probably because I get incorrect results.
This doesn't seem to work as expected :If I have a D3D model and view matrices, how am I supposed to concatenate them correctly, so I can load them in OpenGL as MODELVIEW matrix ?D3DXMatrixScaling(&sca,1,1,-1) ; for(int i = 0 ; i < pOGLMeshes.size() ; i++ ) { OGLMatrix = pOGLMeshes[i]->d3dMatrix * g_Camera->view * sca ; g_pOGLRenderer->RenderMesh(pOGLMeshes[i] , &OGLMatrix[0] ) ; }
Thank you.
d3d:
model * view * projection
ogl:
projection * view * model OR
projection * modelview
(reverse order)
This is because OGL uses column major matrices.
http://en.wikipedia.org/wiki/Column-major_order#Column-major_order
related:
http://www.songho.ca/opengl/gl_transform.html