i’ve just started to progam with opengl and i’ve a little problem with glTranslatef().
when i use x and y it’s moving well on right and up but when i try to move with z the TRIANGLE that i’ve made disappears
anyone know why and can help me ?
sorry for my bad english i’m french.
i’m using dev-cpp.
Thanks a lot.
Looks like you’re moving your triangle behind your zFar-Plane, where it disappears.
Try setting your zFar-Plane further away via gluPerspective.
hum… it’s not working maybe i’ve done something wrong. this this a part of my code:
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0f, 0.0f, -0.01f);
glRotatef (theta, 0.0f, 0.0f, 1.0f);
glColor3f (1.0f, 0.0f, 0.0f); glVertex2f (0.0f, 1.0f);
glColor3f (0.0f, 1.0f, 0.0f); glVertex2f (0.87f, -0.5f);
glColor3f (0.0f, 0.0f, 1.0f); glVertex2f (-0.87f, -0.5f);
theta += 1.0f;
anyone can help me ?
thanks a lot
You make a typical mistake : You don’t watch your matrices!
Things like gluPerspective have to be put into the (guess what) Projection-Matrix, whereas your drawing-calls go into the Modelview-Matrix.
Your code should look like this :
And another typical mistake; the near clip plane in gluPerspective must be positive.