OpenGL Fog not working

Hello!

I can’t make the fog work in my game: it is not “following” the player, it is depending on z-axis.
I already searched for bad GL_PROJECTION matrix, but i only call it once. Here is my rendering code, if anyone could help me, thank you:

public void updateCamera() {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50f, (float) Main.WIDTH / Main.HEIGHT, 0.1f, 64f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glRotatef(pitch, 1.0f, 0.0f, 0.0f);
        glRotatef(yaw, 0.0f, 1.0f, 0.0f);
        glTranslatef(-position.x, -position.y, -position.z);
    }
private void initGL() {
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_CULL_FACE);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_FOG);

        // Setup fog
        FloatBuffer fogColor = BufferUtils.createFloatBuffer(4);
        fogColor.put(0f).put(0f).put(0f).put(1f).flip();
        glFogi(GL_FOG_MODE, GL_LINEAR);
        glFog(GL_FOG_COLOR, fogColor);
        glHint(GL_FOG_HINT, GL_DONT_CARE);
        glFogf(GL_FOG_START, 16f);
        glFogf(GL_FOG_END, 32f);

        glClearColor(0f, 0f, 0f, 1f);
    }
public void render() {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        camera.updateCamera();
        HallwayManager.getInstance().renderHallway();
    }

o-tMnrhtmiA

Here is a video showng my problem. Thanks!

Try not calling each time.

glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(50f, (float) Main.WIDTH / Main.HEIGHT, 0.1f, 64f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

It has to be called only once before the main while loop.

Paul.