So I am doing a simple FPS camera with openGL. I store the camera as 4 vector, a position vector, a lookAt vector, an up vector and a right vector. When the user presses a key, I create a rotation matrix that rotates around the up vector 10 degree then multiply the three vectors that specify the orientation of the camera with it. With these new values I create a new view matrix from glm::lookAt. However, the result I get is very weird. When I press the button to rotate, the object the camera is initially pointing at dissapears, no matter how small I set the rotation. After pressing the rotate button several more time, it appears again, then if i press more it dissappears once more.
I feel like the code is not wrong, but my understanding of the math behind it and therefore the implementation is wrong. Can anyone explain to me this weird behavior? Below is my code.
look = glm::vec3(glm::rotate(theta, axis) * glm::vec4(look, 1.0f)); // theta set at 2 degree right = glm::vec3(glm::rotate(theta, axis) * glm::vec4(right, 1.0f)); up = glm::vec3(glm::rotate(theta, axis) * glm::vec4(up, 1.0f)); glm::mat4 cameraMat = glm::lookAt(eyePos, eyePos+camera.look, camera.up);