PDA

View Full Version : Changing fog settings at runtime



Rapthor
01-23-2007, 10:06 AM
Hello,

I tried to change the fog settings at runtime. But somehow the start and end ranges are incorrect. Testing the same settings right in the code I get a correct fog appearance.

Do I need to clear some fog values before I am able to reinitialize?


Gl.glFogf(Gl.GL_FOG_START, zFar - (zFar / 5f));
Gl.glFogf(Gl.GL_FOG_END, zFar - (zFar / 100f * 5));

Rapthor
01-23-2007, 10:35 AM
Ok, sorry. I found out that fog works great. My problem has another root:

Glu.gluPerspective(fovY, aspect_ratio, zNear, zFar);

This command does not work when executed at runtime. I am changing the value for the far plane but it has no effect (at least the distance I can see is not greater).

Rapthor
01-23-2007, 10:48 AM
Ok I solved it :D

I forgot to switch to PROJECTION and load Identity matrix before changing the perspective:

Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluPerspective(fovY, aspect_ratio, zNear, zFar);
Gl.glMatrixMode(Gl.GL_MODELVIEW);