I'm working on implementing a 2D camera in OpenGL 3.0. I'm currently stuck with determining the "viewing volume" of the camera, so I can perform culling on world coordinates that are outside the camera.
The final matrix used to process verticies is calculated manually by:
The ModelViewProjection matrix is then passed to the GLSL vertex shaders.
Matrix2D ModelViewProjection = ModelMatrix * ViewMatrix * ProjectionMatrix;
The ViewMatrix and ProjectionMatrix both come from the camera.
When the camera is created, ViewMatrix is loaded to the identity matrix and the ProjectionMatrix is loaded with an orthographic projection matrix from 0 to viewportWidth for x, and 0 to viewportHeight for y. The ViewMatrix is then updated to "move the world" based on camera movements, negative translation, negative rotation and then scaling (in that order). The translations of the camera are kept in the camera class (so I have the rotation, translation, etc) -- these don't need to be extracted from the matrix.
My question is, how do I determine if a given world coordinate is visible by the camera? (i.e. it should be drawn)? How do I convert the "camera viewing volume" to world coordinates, it's not the inverse of the ViewMatrix? If I can do that, I can simply check if the given world coordinate is in the camera's "world coordinate viewing volume".
For reference, calculating the ViewMatrix:
And calculating the ModelViewProjection matrix that is passed to the GL shaders:
// we're really moving the 'world', hence negative
Thanks for any input,
void Camera::CalculateModelViewProjectionMatrix(Matrix2D & aModelMatrix) const
// model -> eye
// eye -> clip