Need help with my lookAt function

I made a similar post a couple days ago and now I made some changes to the code and I still don’t thing my lookAt matrix is working. Please help.

EDITED!

mat4 mat4::view(vec3 cameraVector, vec3 targetPos, vec3 upVector)
	{
		mat4 result(1.0f);
		vec3 directionVector = vec3::normalize(cameraVector - targetPos);
		vec3 rightVector = vec3::normalize(vec3::cross(upVector, directionVector));
		vec3 theUpVector = vec3::normalize(vec3::cross(directionVector, upVector));
		
		result.elements[0 + 0 * 4] = rightVector.x;
		result.elements[0 + 1 * 4] = rightVector.y;
		result.elements[0 + 2 * 4] = rightVector.z;
		result.elements[1 + 0 * 4] = theUpVector.x;
		result.elements[1 + 1 * 4] = theUpVector.y;
		result.elements[1 + 2 * 4] = theUpVector.z;
		result.elements[2 + 0 * 4] = directionVector.x;
		result.elements[2 + 1 * 4] = directionVector.y;
		result.elements[2 + 2 * 4] = directionVector.z;
		result.elements[3 + 0 * 4] = cameraVector.x;
		result.elements[3 + 1 * 4] = cameraVector.y;
		result.elements[3 + 2 * 4] = cameraVector.z;

		return result;
	}
  1. Your matrices appear to be transposed. OpenGL (and GLM) uses column-major order, i.e. elements 0, 1, 2, and 3 are the left-hand column, not the top row.
  2. rightVector will actually point to the left; the arguments to vec3::cross() should be the other way around.

This assumes that all of the functions and operators follow the usual conventions (the ones from GLM do).

I’m still taking answers

I’m still taking answers

Please consider that in general it is better to describe which aspect of your question was not answered by a post or what you need more details on.

Take a look at gluLookAt for how the matrix is assembled.

[QUOTE=carsten neumann;1280648]Please consider that in general it is better to describe which aspect of your question was not answered by a post or what you need more details on.

Take a look at gluLookAt for how the matrix is assembled.[/QUOTE]

Like I said I need some feedback to see if my matrix is alright just like what my title says. I don’t need any other information. I just need to see if I did the math right. I’m just a beginner so take it easy on me.

Please I need help I want to do some 3D Graphics! PLS!!!

The theUpVector should have the rightVector in there not upVector. My bad.