Fog question: very strange fog problem.

Whenever I enable fog, the fog starts at the very first and then fades out and fades in again, its like this:

I’m sure more than one got this problem before (right?). But I couldnt find any related.

Shouldnt the fog start and appear? what I mean is, in DX for example the fog shows up at the end only, this is the idea of fog, at least mine.

I’m using linear fog, maybe this is the problem? why does it start then fades out and start again?

Side question: Why are the forums so slow? when I click on a link it takes 5 seconds minimum to start retrieving data from the server…

Post the matrix, fog and geometry setup which generated this image.
Wild guess: Do not put the camera transformation inside the projection matrix, it belongs into the modelview matrix for fog to work.

hi im getting a similar problem! heres what im doing
i dont have my other pc handy so ill tell you from my memory

i call gl clear here
i put matrixmode to gl_projection
i call loadidentity
i set the perspective in glu
i set the lookat in glu
i put matrixmode to gl_modelview

and i get the same problem but if i put modelview before calling lookat, the problem seems gone but i can not move my “camera” using lookat, how can i move the camera then? is there any other way of doing this? i dont know of any command in opengl!!!

Well, you don’t usually need to change your view frustum every frame. So the usual thing is:

void reshape(int w, int h)
{
  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho, glFrustum, gluPerspective etc. your choice
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}

and in your display function:
void display()
{
  glClear(your buffers);
  glLoadIdentity();
  gluLookAt(...);

  draw your stuff;

  glFlush();
  SwapBuffers();
}

Also, I’m not sure, but if my memory serves me well, there could be a repeating factor or something in the fog functions? You might want to check the help files on them. Good luck!

RTFAQ:
http://www.opengl.org/resources/faq/technical/viewing.htm#view0030

well i am doin what you suggested but i still can t move my camera why could this be? i dont have sources here with me im at school for a long period but i wanted to know what could be the problem because i remember the camera working before when using the projection and modelview differently

Well, the problem must lie within your display function probably. Try putting some simple simple stuff like a glRecti and see if this works.
When you say move the camera, you mean changing a value in gluLookAt and expect to see a change in your view right? Could it be that your using a glLoadIdentity() further down your display function? That would cancel out a gluLookAt.

im calling glulookat at the bottom of my loop just before swapbuffers and also tried at the top of the loop yesterday and that didnt made any change.

yes i meant to change the lookat values with “move camera”

is there any other way of making a “camera” instead of using glulookat ???

i dont know why it isnt working

Post your display function. When you draw objects, the vertices get transformed by the matrix state at the time the vertex is declared (with glVertex). If you put your gluLookAt in the bottom, then nothing gets transformed. gluLookAt is as good as a camera as you’re going to get, if you don’t create a camera class (or find one). Try to find an article on how it works, it’s rather simple really.

Originally posted by bansheeogl:
[b]hi im getting a similar problem! heres what im doing
i dont have my other pc handy so ill tell you from my memory

i call gl clear here
i put matrixmode to gl_projection
i call loadidentity
i set the perspective in glu
i set the lookat in glu
i put matrixmode to gl_modelview

and i get the same problem but if i put modelview before calling lookat, the problem seems gone but i can not move my “camera” using lookat, how can i move the camera then? is there any other way of doing this? i dont know of any command in opengl!!![/b]
Doing your lookat on the modelview is the right way, however you should loadidentity THEN lookat, i.e. loadidentity on your modelview too.

If you still can’t move with a lookat then you have some other problem, either a bug in your code (almost certainly) and/or a conceptual problem with what you expect OpenGL should be doing.

You cannot put gluLookAt in projection matrix for reasons as in

http://sjbaker.org/steve/omniv/projection_abuse.html

Originally posted by bansheeogl:
[b]hi im getting a similar problem! heres what im doing
i dont have my other pc handy so ill tell you from my memory

i call gl clear here
i put matrixmode to gl_projection
i call loadidentity
i set the perspective in glu
i set the lookat in glu
i put matrixmode to gl_modelview

and i get the same problem but if i put modelview before calling lookat, the problem seems gone but i can not move my “camera” using lookat, how can i move the camera then? is there any other way of doing this? i dont know of any command in opengl!!![/b]