Hello,
I've got some problems when using fog in my program.
I display a cube (with LWJGL) which is rotating on the screen. Without fog : no problems. But when I turn the fog on, the cube's faces suddenly "blink".
I was thinking about a double buffer problem but apprently double buffer is by default enabled with LWJGL and moreover I've got no probem without the fog.
If someone have an idea...
Here's some snippet of my code :
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
//If I coment this line, no problem appears
glEnable(GL_FOG);
glViewport(0,0,800,600);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(float) 800/600,1.f,1000.f);
gluLookAt(400,400,400,100,100,100,0,1,0);
MAIN LOOP :
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
yAngleCube+=0.1f%360.f;
glMatrixMode(GL_MODELVIEW);
glPushMatrix(); //SAUVE la matrice actuelle
glRotatef(yAngleCube, 0.f, 1.f, 0.f );
//Cube
glBegin(GL_QUADS);
glColor3f(0.0f, 1.0f, 1.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(200.0f, 0.0f, 0.0f);
glVertex3f(200.0f, 200.0f, 0.0f);
glVertex3f(0.0f, 200.0f, 0.0f);//face sur le plan z=0
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 200.0f, 0.0f);
glVertex3f(0.0f, 200.0f, 200.0f);
glVertex3f(0.0f, 0.0f, 200.0f);//face sur le plan x=0
glColor3f(1.0f, 0.0f, 1.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(200.0f, 0.0f, 0.0f);
glVertex3f(200.0f, 0.0f, 200.0f);
glVertex3f(0.0f, 0.0f, 200.0f);//face sur le plan y=0
glColor4f(0.0f, 0.0f, 1.0f,0.8f); //face transparente !!
glVertex3f(0.0f, 0.0f, 200.0f);
glVertex3f(200.0f, 0.0f, 200.0f);
glVertex3f(200.0f, 200.0f, 200.0f);
glVertex3f(0.0f, 200.0f, 200.0f);//face sur le plan z=200
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(200.0f, 0.0f, 0.0f);
glVertex3f(200.0f, 200.0f, 0.0f);
glVertex3f(200.0f, 200.0f, 200.0f);
glVertex3f(200.0f, 0.0f, 200.0f);//face sur le plan x=200
glColor3f(0.0f, 1.0f, 0.0f);
glNormal3f(0.f,-1.0f,0.0f);
glVertex3f(0.0f, 200.0f, 0.0f);
glVertex3f(200.0f, 200.0f, 0.0f);
glVertex3f(200.0f, 200.0f, 200.0f);
glVertex3f(0.0f, 200.0f, 200.0f);//face sur le plan y=200
glEnd();
glPopMatrix(); //restore la matrice
//actualisation de l'affichage
Display.update();
Le Worgle
PS : I'm french, sorry for my bad english...