compiler warning

I’m trying to write a GLSL vertex shader and am getting a compiler error on the following line:

const float fogDensity = gl_Fog.density;

warning C1059: non constant expression in initialization

the code looks alright to me. Anybody have an idea why I’d be getting this warning and how to resolve it?

constants in GLSL really must be constants, you can’t assign a value like that to it.

So:

const float fogDensity = 0.5;

is fine.

In other words, the constant’s value must been know at compile time.

Regards
elFarto

Good to know. Thanks.