PDA

View Full Version : Draw distance?

Brokenlynx
02-18-2008, 11:19 AM
Hiya just a quick question Im coding a class showing a diagram of a pendulum with opengl embedded in an MFC window. Initially I set the transform so that the model appears in the viewport. However my model only appears visible between certain values for z in glTransform() (these values being between 3-7 where it appears my model is at the origin and should be visible further out. Heres my code:

GLvoid CCubeView::glDrawScene2(void) // Here's Where We Do All The Drawing
{
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);
glTranslatef(0.0f, 0.0f, z); // Z sets initial viewpoint
//TODO:: Viewpoint Manipulation (is Y down?)
//glTranslatef(z,xspeed,yspeed); // Z sets initial viewpoint
//glTranslatef(0.0f,0.0f,z);

glRotatef(270.0f,1.0f,0.0f,0.0f);
angle = rk4_step(t, yin, yout, 0.016, singlePendulum);
//TODO: Angle only properly implemented for double pendulum case.

glRotatef(angle[0],0.0f,1.0f,0.0f);
//TODO: Originally used for rotation

//glBindTexture(GL_TEXTURE_2D, texture[filter]);
glColor3f(0.0f, 0.0f, 1.0f);
glTranslatef(0.0f,0.0f,-3.0f); // Center The Cylinder
gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32); // A Cylinder With A Radius Of 0.5 And A Height Of 2
glColor3f(1.0f, 0.0f, 0.0f);
gluSphere(quadratic,0.2f,32,32); // Draw A Sphere With A Radius Of 1 And 16 Longitude And 16 Latitude Segments

glRotatef(angle[1],0.0f,1.0f,0.0f);
glColor3f(1.0f, 0.0f, 1.0f);
glTranslatef(0.0f,0.0f,-3.0f); // Center The Cylinder
gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32); // A Cylinder With A Radius Of 0.5 And A Height Of 2
glColor3f(0.0f, 1.0f, 0.0f);

glFinish();
SwapBuffers(wglGetCurrentDC());
//return TRUE; // Keep Going
}

The part im referring to is just near the beginning:

glTranslatef(0.0f, 0.0f, z); // Z sets initial viewpoint

-NiCo-
02-18-2008, 11:50 AM
I'm not sure what the question is... using a question mark would help ;)

I guess you're having problems with the near and far clipping planes, but I don't see any code where you set the GL_PROJECTION matrix.

N.

Brokenlynx
02-18-2008, 12:03 PM