dreamspaced

10-17-2005, 02:53 AM

Hi,

I had an engine up and running in managed directx, that using direct x's matrix classes had rotate, move, translate functionality. I've started a new engine in Opengl and wish to retain this functionality but doing so is proving..impossible.

I've tried copying the matrix into a float array, and using glLoadMatrix to use the matrix. I've tried flipping the matrix, reversing order, but always with the black screen.

When I simply used glLoadIdentity,glRotateF(0,1,0,0) etc to put it in the same place, it worked. A white screen as the camera was inside a cube.

Here's the C# code I use to convert matrixes. Can you see where I'm going wrong here?

public void SyncGL2(Matrix mat)

{

vmat[0] = mat.M41;

vmat[1] = mat.M31;

vmat[2] = mat.M21;

vmat[3] = mat.M11;

vmat[4] = mat.M42;

vmat[5] = mat.M32;

vmat[6] = mat.M22;

vmat[7] = mat.M12;

vmat[8] = mat.M43;

vmat[9] = mat.M33;

vmat[10] = mat.M23;

vmat[11] = mat.M13;

vmat[12] = mat.M44;

vmat[13] = mat.M34;

vmat[14] = mat.M24;

vmat[15] = mat.M14;

}Mat is a directX object.

Here's the rendering code I use.

Matrix mat = Matrix.Invert(world);

SyncGL2(mat);

Gl.glLoadMatrixf(vmat);

entity.SyncGL2(entity.WorldMatrix());

Gl.glMultMatrixf(entity.GetGLMat());

entity.RenderNative();In english, I first load the converted camera matrix into gl, then convert the object matrix into gl and then multiply that with the current (Camera) matrix.

I had an engine up and running in managed directx, that using direct x's matrix classes had rotate, move, translate functionality. I've started a new engine in Opengl and wish to retain this functionality but doing so is proving..impossible.

I've tried copying the matrix into a float array, and using glLoadMatrix to use the matrix. I've tried flipping the matrix, reversing order, but always with the black screen.

When I simply used glLoadIdentity,glRotateF(0,1,0,0) etc to put it in the same place, it worked. A white screen as the camera was inside a cube.

Here's the C# code I use to convert matrixes. Can you see where I'm going wrong here?

public void SyncGL2(Matrix mat)

{

vmat[0] = mat.M41;

vmat[1] = mat.M31;

vmat[2] = mat.M21;

vmat[3] = mat.M11;

vmat[4] = mat.M42;

vmat[5] = mat.M32;

vmat[6] = mat.M22;

vmat[7] = mat.M12;

vmat[8] = mat.M43;

vmat[9] = mat.M33;

vmat[10] = mat.M23;

vmat[11] = mat.M13;

vmat[12] = mat.M44;

vmat[13] = mat.M34;

vmat[14] = mat.M24;

vmat[15] = mat.M14;

}Mat is a directX object.

Here's the rendering code I use.

Matrix mat = Matrix.Invert(world);

SyncGL2(mat);

Gl.glLoadMatrixf(vmat);

entity.SyncGL2(entity.WorldMatrix());

Gl.glMultMatrixf(entity.GetGLMat());

entity.RenderNative();In english, I first load the converted camera matrix into gl, then convert the object matrix into gl and then multiply that with the current (Camera) matrix.