PDA

View Full Version : pls help



redorion
10-18-2003, 08:23 AM
Hello..pls advice me on this.
I just learnt how to draw 2D objects and I would like to try out 3D objects. I already set the glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable(GL_DEPTH_TEST);
and I also changed the glvertex to include x,y,z coordinates. The problem is it only draws out the object if all the vertex has same z values.. I cant draw a cube or anything. In other words I cant get a 3D object out. What exactly is the problem..?
thankx http://www.opengl.org/discussion_boards/ubb/smile.gif

10-18-2003, 09:19 AM
Have you rotated the camera to see your object from another point of view? Try using
gluLookAt(10, 0, 0, 0, 0, 0, 0, 1, 0);
to position your camera 10 units on the x-axis, 0 on y and z, looking at the center, and having an up vector.

gvm
10-18-2003, 09:26 AM
first, set your projection like this:
resizefunc()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (float)width/height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}
void draw()
{
glLoadIdentity();
gluLookAt(0,0,10,0,0,0, 0,1,0);
//...drawing code
glSwapBuffers()
}