Can't make object 3d

glPushMatrix();
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex3f(-3.0, 0.0, 0.0);
glVertex3f(-2.0, 2.0, 0.0);
glVertex3f(-1.0, 0.0, 0.0);
glEnd();
glPopMatrix();

glPushMatrix();
glColor3f(0.0,1.0,0.0);
glBegin(GL_POLYGON);
	glVertex3f(0.0, 0.0, 0.0);
	glVertex3f(0.0, 1.0, 0.0);
	glVertex3f(1.0, 1.0, 0.0);
	glVertex3f(1.0, 0.0, 0.0);
glEnd();
glPopMatrix();

glColor3f(0.0, 0.0, 1.0);
glBegin(GL_POLYGON);
	glVertex3f(3.0, 0.0, 0.0);
	glVertex3f(5.0, 0.0, 0.0);
	glVertex3f(5.0, 2.0, 0.0);
	glVertex3f(4.0, 3.0, 0.0);
	glVertex3f(3.0, 2.0, 0.0);
glEnd();

The code shown when run displays a red triangle, a green rectangle, and a blue house shape. They are 2D, and I can’t quite seem to make them 3D. I tried putting values in for the z axis, but when I do the window display is all messed up.

Set up your projection matrix correctly? Are you using GluPerspective or something similar?

hahaha i dont see a blue house

besides u only have enuf code for only 3 polys
how do u expect to see anything in 3d

if u were to rotate the 3 polys u have now
u might get a 3d sort of funky looking shape

other than that ur code is rendering correctly

You don’t make the object 3D, it is either planar or spatial, but anyway projection makes all objects 2D, it projects them on a plane. I recommend that you do some more tuts over from NeHe and play around a little with the modelview matrix to get the “3D” feeling :slight_smile:

There’s also http://library.nu for your reading pleasure.