drawing problem

I cannot get this quad to draw unless I have it’s Z coordinates set to > -1.0f. I have the near and far plane set to 0.1 and 100, and it shows up if I use -1.0f as the Z coordinates, but not if I go less then that.

I have a valid device context, valid opengl rendering context, etc…

This is how I setup the projection matrix:


	if (!h) {
		h = 1;										
	}

	glViewport (0, 0, w, h);						
	
	glMatrixMode (GL_PROJECTION);						
	glLoadIdentity ();

	gluPerspective (60, (float)w/(float)h, 0.1f, 100.0f); 

	glMatrixMode (GL_MODELVIEW);							
	glLoadIdentity ();

And this is how I draw:


	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode (GL_MODELVIEW);
	glLoadIdentity ();

	glTranslatef (0, 0, -6.0f);
	glBegin (GL_QUADS);
	glVertex3f (0.5f, -0.5f, 0.0f);
	glVertex3f (0.5f, 0.5f, 0.0f);
	glVertex3f (-0.5f, 0.5f, 0.0f);
	glVertex3f (-0.5f, -0.5f, 0.0f);
	glEnd ();

	SwapBuffers (r_context);

Giving Z as 0.0f would definitely not work. That is behind the specified near plane.

Try to visualize the frustum and verify if your object is within the view frustum.

Convert the gluPerspective() to glFrustum() or just manually try checking if the quad is within the view volume.

But it’s translated into the screen -6.0f before I do the vertices, shouldn’t that make it inside the view frustrum?