Fog error?!? or my error?!?!

Ok, I had an application where i had a car driving around on a flat ground. I decided to add fog. Not knowing how to do this, i decided to visit for the fog tutorial. Ok, I cut and pasted the fog code, adjusted the beginning and end depths for the fog and behold, there was fog.
Now here his my question, do I have to update the fog begin/end depths every frame? When my car moves around, my camera follows using gluLookAt. The fog seems to only stay in one position. I can drive straight through the fog and when I pass the end depth for the fog, it ends. and there is no fog.

Am I wrong to think that you should never be able to drive through the fog completely?
Shouldn’t it stay at a certain depth into the screen. In any FPS with fog, you never end up walking through the fog (unless volumetric).

sorry, dont know if this is important…
Windows xp pro, Visual Studio 6.0, Intel integrated 810 video with most recent (xp compatable) driver.

If you have called glMatrixMode(GL_PROJECTION) without calling glMatrixMode(GL_MODELVIEW) again before gluLookAt the fog won’t work.
You don’n need to update your fog begin/end every frame.

It should look someting like this;

//Sett upp you projetion matrix here
gluLookAt(0.0, …);
and the rest of the code here.

[This message has been edited by teknicida (edited 03-20-2002).]

Are you sure youre using the right fog mode?
I had the same problem when I was uding linear fog.

This code works fine for me:

Fog start and end is only used with linear fog .


I’m guessing teknicida is right. If you try and do “camera-like” transforms in the projection matrix, you can mess up the fog calculations. Just using the wrong fog mode wouldn’t cause what you are seeing.

You mentioned flat ground, is it only one big quad? If it is, tesselate it to many smaller quads, because fog is calculated per vertex.