Hello,
I’ve decided to add fog to my rendering engine. After I setup and enable fog however, the scene is fogged a constant amount irrespective of the depth (ie, objects at the near clip plane are fogged just as much as objects at the far clip plane). I set up fogging as shown in the GL red book, like so:
// gl is a struct I have to hod my GL globals
gl->fog_start= 0.f;
gl->fog_end= 10000.f; // far clip plane distance
gl->fog_density= 0.35f;
gl->fog_color.r= 0.f;
gl->fog_color.g= .5f; // make fog green so it’s easy for me to see
gl->fog_color.b= 0.f;
gl->fog_color.a= 1.f;
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glHint(GL_FOG_HINT, GL_DONT_CARE);
glFogf(GL_FOG_DENSITY, gl->fog_density);
glFogf(GL_FOG_START, gl->fog_start);
glFogf(GL_FOG_END, gl->fog_end);
glFogfv(GL_FOG_COLOR, (float *)&gl->fog_color);
glClearColor(gl->fog_color.r, gl->fog_color.g, gl->fog_color.b, gl->fog_color.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Does anyone have any ideas what might cause OpenGL to behave in this fashion? Any help is greatly appreciated!