OpenGL GLM camera matrix problem
Posted: Wed Jun 01, 2011 7:51 pm
Hello everyone,
I am having a tad issue with updating the Quake renderer code to OpenGL 3.x+. The problem is the camera. I cannot use gluPerspective anymore so I'm using the GLM library. It works sort of, here is my code.
Also here is an image showing the problem.
http://i.imgur.com/8CskY.jpg
(the sky is to the left, and when I jump the camera moves to the right, at all times no matter the rotation)
The scene feels rotated by 90 degree's and the rotations feel like it's rotating around the player in a big arch.
I'd greatly appreciate any help, I've been stuck on this for a while. I feel like I'm missing something obvious.
I am having a tad issue with updating the Quake renderer code to OpenGL 3.x+. The problem is the camera. I cannot use gluPerspective anymore so I'm using the GLM library. It works sort of, here is my code.
Code: Select all
projectionMatrix = glm::perspective(r_refdef.fov_y, (float)vid.width / (float)vid.height, 0.01f, 8192.0f);
viewTransMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(-r_origin[2], -r_origin[1], -r_origin[0]));
viewRotMatrix = glm::rotate(viewTransMatrix, -r_refdef.viewangles[0], glm::vec3(1.0f, 0.0f, 0.0f));
viewMatrix = glm::rotate(viewRotMatrix, -r_refdef.viewangles[1], glm::vec3(0.0f, 1.0f, 0.0f));
modelMatrix = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
http://i.imgur.com/8CskY.jpg
(the sky is to the left, and when I jump the camera moves to the right, at all times no matter the rotation)
The scene feels rotated by 90 degree's and the rotations feel like it's rotating around the player in a big arch.
I'd greatly appreciate any help, I've been stuck on this for a while. I feel like I'm missing something obvious.