PDA

View Full Version : Can't make object 3d



gasper91
03-20-2011, 02:42 PM
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();

gasper91
03-20-2011, 02:43 PM
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.

Red_Riot
03-20-2011, 03:23 PM
Set up your projection matrix correctly? Are you using GluPerspective or something similar?

enjoycrf
03-20-2011, 06:33 PM
hahaha i dont see a blue house

enjoycrf
03-20-2011, 06:37 PM
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

ugluk
03-21-2011, 06:32 AM
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 :)

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