Title: Good Practices for updating camera matrix
Tags: opengl;camera
Question: I'm learning OpenGL right now, specifically how to move a camera. If I wish to change my camera matrix, for example, if the user is translating it with WASD, there are two primary ways I could do this:
Pre-multiply the camera matrix by the new translation matrix.
Manage a set of attributes for the camera, such as position, viewing angle, up-vector, modify those, and re-compute the camera matrix from these.
Which of these is considered better? I feel like the first would introduce drift, and the second would require more computation, but I don't know enough to analyze the two.

Here is the accepted answer: One of the easiest way to model camera is to use 'lookAt' system. Basically you remember camera_pos, camera_target, optionally camera_up vectors. Then you build final matrix using old gluLookAt or some modern way like glm75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0lookAt.
That way it is easier to model camera and its parameters.
here are some links:
http://www.opengl.org/archives/resources/faq/technical/viewing.htm
http://www.codeproject.com/Articles/84698/OpenGL-Camera
http://www.songho.ca/opengl/gl_transform.html
Do not look that much at the performance cost. First learn something, build it... then optimize if needed.
Comment for this answer: 'premature optimization' is not only your problem :)
Comment for this answer: Yeah, it does fall under 'premature optimization', but since I'll end up doing this frequently, and so many people have done it before, I figured it'd make sense to ask early. Anyways, thank you!
Comment for this answer: Don't spend too much time worrying about the computation time. Make it work and optimize if needed. I highly doubt that it will become a problem as long as you don't start recomputing it ten thousands of times per frame. Compute it once.. and pass it to your shader.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:05/05/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<opengl><camera>', 'Title': 'Good Practices for updating camera matrix', 'ViewCount': 139, 'id': 16390378, 'user_AboutMe': '<p>I used to study math at Caltech, and then I went into the tech industry. But I still do math recreationally, like the addict that I am.</p>\n<p>Things I am trying to learn about, in the form of media titles:</p>\n<ul>\n<li>Generating Functions and Where To Find Them</li>\n<li>Dr. Homology or: How I Learned to Stop Worrying and Love the Diagram</li>\n<li>Alexander and the Inseparable, Ramified, Non-Abelian, Very Large Extension</li>\n</ul>\n\n', 'user_AccountId': 2216552.0, 'user_DisplayName': 'Henry Swanson', 'user_Reputation': 186.0, 'user_Views': 60.0, 'user_id': 1957028.0}}