I've been working on a game engine and recently got to the point where I could easily create a Camera class to manage a view matrix (or allow an easy switch to another). I know conceptually what it must do, but where I'm having trouble is figuring out how to rotate about the local origin (for the view matrix, it would be the same as the translation matrix that is multiplied into a rotation matrix).
I know that in direct mode, you would
glTranslatef(x, y, z); //move back to origin
glRotatef(angle, x_rot, y_rot, z_rot); //turn using a quaternion
glTranslatef(-x, -y, -z); //move back to original location
but I'm not sure how that would translate to a more modern application. Would you do essentially the same thing, make a translation matrix back to origin, rotate, and translate back? For every single object you want to rotate? From what I've tested so far, that method works for viewing, but controlling that in 3D space is unwieldy (I'm not sure how to adjust for the rotation constantly. Convert movement components into a single vec4, multiply by the rotation, apply to the translation, then do the actual rotation?)
It seems like there's a more efficient way than doing three or more 4x4 matrix multiplications that I'm missing.
Here's the specific section after trying out a suggested solution.