PDA

View Full Version : Strange fog problem.



Johnson.N.M.B
08-06-2006, 08:37 PM
Here is a piece of code:

// Set red fog some where
GLfloat red[4] = {1,0,0,0};
glFogfv (GL_FOG_COLOR, red);
...
// Here set black fog
GLfloat black[4] = {0,0,0,0};
glFogfv (GL_FOG_COLOR, black);
glDrawElements(... ...);

This produces black fogged scene, as we expected.
now, I change the code to:

// Set red fog some where
GLfloat red[4] = {1,0,0,0};
glFogfv (GL_FOG_COLOR, red);
...
// Here set black fog
glPushAttrib (GL_FOG_BIT); // Added
GLfloat black[4] = {0,0,0,0};
glFogfv (GL_FOG_COLOR, black);
glDrawElements(... ...);
glPopAttrib (GL_FOG_BIT); // Added

Now the scene is rendered with red fog! Why? It's quite strange, and it happens with both ATI X700 and NVidia FX5200.

Kyeotr
08-07-2006, 12:28 AM
Is it possible that you've somehow exceeded the maximum attribute stack depth?

Are you getting any errors?

Johnson.N.M.B
08-07-2006, 06:36 PM
No, no any errors. If i change the code to:

GLfloat c[4];
glGetFloatv(GL_FOG_COLOR, c);
GLfloat black[4] = {0,0,0,0};
glFogfv (GL_FOG_COLOR, black);
glDrawElements(... ...);
glFogfv (GL_FOG_COLOR, c);

This doesn't work too.

rgpc
08-08-2006, 06:39 PM
Try a glFlush/glFinish (?) just before the glPopAttrib. I wouldn't think this would/should make a difference but that's the only thing I can see that might be a problem.

Komat
08-09-2006, 01:21 AM
Do you use shaders or fixed function pipeline? Some drivers were not correctly updating the fog parameters inside the shaders until next time the shader was bound.

V-man
08-09-2006, 06:48 AM
I have seen such an effect. When you don't render anything yet, calls to glFogfv(GL_FOG_COLOR, ...) work, but it seems as if after, they are ignored. I have this one project that does it and it still doesn't work now that I tried it. Radeon 9700 with Cat 6.7