How can I create a fog? Just something easy, nothing fancy. Code is appreciated…
Thanx
How can I create a fog? Just something easy, nothing fancy. Code is appreciated…
Thanx
HI
here it is a piece of code to enable fog
this one should clear the screen on the color of the fog you have defined
glClearColor(0.3f,0.3f,0.3f,1.0f);
glFogi(GL_FOG_MODE, GL_LINEAR); //
Instead of GL_LINEAR you can also try GL_EXP and GL_EXP2
glFogfv(GL_FOG_COLOR, fogColor);
the fogcolor variable should be on the same color as the one from glClearColor
glFogf(GL_FOG_DENSITY, 0.15f);
This one defines the density of the fog
glHint(GL_FOG_HINT, GL_DONT_CARE);
This one i really don’t know
glFogf(GL_FOG_START, 1.0f);
glFogf(GL_FOG_END, 5.0f);
Fog_start and Fog_end, is from where the fog begin and where it ends.
glEnable(GL_FOG);
I believe using fog, makes the render more realistic and much faster, because objects that are behind the fog are not computed
hope this helps
Bruno
Thanx! Just the kind of answer I wanted.