I'm trying to set the far clipping plane to a higher value, but I'm a bit lost.
I'm looking at a complex object using a QMatrix4x4 camera persepective like that:
glMatrixMode(GL_MODELVIEW);
m_view = QMatrix4x4();
m_view.lookAt(QVector3D(17.f, 36.f, 36.f), // eye
QVector3D(17.f, 0.f, 19.f), // center
QVector3D( 0.f, 0.f, -1.f)); // up
glLoadMatrixf(m_view.data());
Now, looking from this perspective, my object is being clipped by the far plane.
I've tried to increase the far plane distance by using a frustum matrix operation with a huge value. All I want is to modify the back clipping plane:
m_view.frustum(1.f, 1.f, 1.f, 1.f, 1.f, 200000.f);
But this does not show any difference, modifying the farPlane
parameter does not change anything. The same applies to ortho:
m_view.ortho(1.f, 1.f, 1.f, 1.f, 1.f, 200000.f);
Or perspective:
m_view.perspective(0.f, 1.f, 1.f, 200000.f);
What's wrong with my approach? How to modify the far clipping plane?
Edit
I've extended the code snippets above as the problem was not visible. Obviously my mistake was modifying the GL_MODELVIEW
instead of the GL_PROJECTION
.
Working code should look like that:
// Projection
m_projection = QMatrix4x4();
m_projection.perspective(20.f, m_width / m_height, 0.01f, 2000.f); // note the far plane
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(m_projection.data());
// Model view
m_view = QMatrix4x4();
m_view.lookAt(QVector3D(17.f, 36.f, 36.f), // eye
QVector3D(17.f, 0.f, 19.f), // center
QVector3D( 0.f, 0.f, -1.f)); // up
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(m_view.data());