Original Post
Hi there ! I'm new to openGL and I'm reading the red book. I want to draw a cube which move slowly on the z axis until a fixed value. So I declare this variables : and here is my render() function : and the results is weird... My screen is blank (that is because the cube is first draw at 0,0,0) and after one second or two my screen is black and that's all. If I directly put currentZTranslation = -6.0f it's ok, the cube is correctly displayed. What's wrong in my code ? :-( Thanks a lot for your help !
private float maxZTranslation = -6.0f;
private float currentZTranslation = 0.0f;
private void render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // Clear The Screen And The Depth Buffer
GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glLoadIdentity(); // Reset The Current Modelview Matrix
GL11.glTranslatef(0.0f, 0.0f, currentZTranslation);
GL11.glBegin(GL11.GL_QUADS);
..... //Drawing each faces
GL11.glEnd();
if(currentZTranslation>maxZTranslation){
currentZTranslation -= 0.05f;
}
}