Code: Select all
void OpenGLRenderTarget::updateMatrix() const
{
const double w = d_area.getWidth();
const double h = d_area.getHeight();
const double aspect = w / h;
const double midx = w * 0.5;
const double midy = h * 0.5;
d_viewDistance = midx / (aspect * d_yfov_tan);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(30.0, aspect, d_viewDistance * 0.5, d_viewDistance * 2.0);
// Projection matrix abuse!
gluLookAt(midx, midy, -d_viewDistance, midx, midy, 1, 0, -1, 0);
glGetDoublev(GL_PROJECTION_MATRIX, d_matrix);
glPopMatrix();
d_matrixValid = true;
}