Original Post
Im using gluPerspective(..) to set up my view of an openGL scene consisting of two objects. I am trying to increase the far clipping plane as Im currently unable to view the object from distances of less than z = -35.0f despite my far clipping plane being much larger than that farplane = 100; I'll paste some code any help with this is appreciated. [Edited by - brokenlynx on March 9, 2008 11:16:14 PM]
void CCubeView::Init()
{
PIXELFORMATDESCRIPTOR pfd;
int n;
HGLRC hrc;
GLfloat fMaxObjSize, fAspect;
GLfloat fNearPlane, fFarPlane;
m_pDC = new CClientDC(this);
ASSERT(m_pDC != NULL);
if (!bSetupPixelFormat())
return;
n = ::GetPixelFormat(m_pDC->GetSafeHdc());
::DescribePixelFormat(m_pDC->GetSafeHdc(), n, sizeof(pfd), &pfd);
CreateRGBPalette();
hrc = wglCreateContext(m_pDC->GetSafeHdc());
wglMakeCurrent(m_pDC->GetSafeHdc(), hrc);
GetClientRect(&m_oldRect);
glClearDepth(0.0f);
glEnable(GL_DEPTH_TEST);
if (m_oldRect.bottom)
fAspect = (GLfloat)m_oldRect.right/m_oldRect.bottom;
else // don't divide by zero, not that we should ever run into that...
fAspect = 1.0f;
//fNearPlane = 3.0f;
//fFarPlane = -50.0f;
fMaxObjSize = 3.0f;
m_fRadius = fNearPlane + fMaxObjSize / 2.0f;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluPerspective(45.0f, fAspect, fNearPlane, fFarPlane);
gluPerspective( 90,2.0,0.1,100 ); //Farplane set to 100 still invisible
quadratic = gluNewQuadric();
}
......
GLvoid CCubeView::glDrawScene4(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); // Reset The View
glTranslatef(-17.0f, 1.0f, -45.0f); // Z sets initial viewpoint (works only with z > -35.0f)
glRotatef(270.0f,1.0f,0.0f,0.0f);
angle = rk4_step(t, yin, yout, 0.016, singlePendulum);
float *glInputs = new float[2];
glInputs[0] = angle[0]*(3.0f); //Breacketed values used to constrain lateral motion in view
glInputs[1] = angle[1]*(3.0f);
glTranslatef(5.0f,0.0f,0.0f);
glTranslatef(glInputs[0],0.0f,0.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glTranslatef(0.0f,0.0f,-3.0f); // Center The Cylinder
DrawOblong(2.0f);
glTranslatef(-10.0f, 0.0f, 3.0f);
glTranslatef(glInputs[1],0.0f,0.0f);
glTranslatef(0.0f,0.0f,-3.0f); // Center The Cylinder
glColor3f(1.0f, 0.0f, 0.0f);
DrawOblong(2.0f);
glTranslatef(0.0f, 0.0f, -1.0f);
glFinish();
SwapBuffers(wglGetCurrentDC());
//return TRUE; // Keep Going
}