Hi Guys,

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 onworld coordinatesthat 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.Code:`Matrix2D ModelViewProjection = ModelMatrix * ViewMatrix * ProjectionMatrix;`

TheViewMatrixandProjectionMatrixboth come from the camera.

When the camera is created,ViewMatrixis loaded to the identity matrix and theProjectionMatrixis loaded with an orthographic projection matrix from0toviewportWidthforx, and0toviewportHeightfory. TheViewMatrixis 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 theViewMatrix? 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 theViewMatrix:

And calculating theCode:`void Camera::UpdateViewMatrix()`

{

myViewMatrix.LoadIdentity();

// we're really moving the 'world', hence negative

myViewMatrix.Translate(-myPosition.GetX(), -myPosition.GetY());

myViewMatrix.Rotate(-myRotation);

myViewMatrix.Scale(myZoomFactor, myZoomFactor);

}

ModelViewProjectionmatrix that is passed to the GL shaders:

Thanks for any input,Code:`void Camera::CalculateModelViewProjectionMatrix(Matrix2D & aModelMatrix) const`

{

// model -> eye

aWorldMatrix.Multiply(GetViewMatrix());

// eye -> clip

aWorldMatrix.Multiply(GetProjectionMatrix());

}

Zac