Make objects slowly vanish using blending

I plan to make objects slowly vanish when distancing from the camera. Theoretically I should use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), but it’s not working in my context, so I should be missing something.

I’m working with textured objects, GL_MODULATE, and lights enabled.

The code follows:


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4F(1,1,1,alfa);
glEnable(GL_CULL_FACE);


glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, FSkinID[0]);
//starts drawing with gl_begin(GL_TRIANGLE_FAN)

The alfa values range from 0 to 1 according with camera distance.
This code results in a normal drawing with no blending.

It should work this way, isn’t it?

When lighting is enabled material parameters (set with glMaterial) are used for calculations. Vertex colours are only considered if you set your material to track the current colour using glColorMaterial.

You’re right! I just set the alpha value for the material and the blending worked like a charm! Thank you!