gl_PointCoord issue

When I try to use gl_PointCoord in my fragment shader to make point sprites its value is always 0,0.

It would be great if someone provided me with a working example(with source) that uses gl_PointCoord to texture map point sprites(preferably for Windows) so I can see myself what I have done wrong(or if it is a driver problem), otherwise you can still suggest possible sources of error. Any help is appreciated.

I am pretty sure I have all the enables I need:


glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glEnable(GL_POINT_SPRITE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);

But in my fragment shader gl_PointCoord is 0,0 no matter what.

Meanwhile I have ‘emulated’ gl_PointCoord by converting the position of the vertex after it is multiplied by the matrix into screen coordinates and storing this in a varying, and then using this value with gl_FragCoord to calculate the difference and and divide with point size to get values ranging from 0 to 1…hopefully you understand but this is not really relevant to the problem.

edit: to not have to create a topic for such a simple question, is dividing a fixed starting value by the depth the way to go to do point sprite distance attenuation?

Hi,
You may check the following page where I am using the gl_PointCoord to render point sprites as spheres.

http://mmmovania.blogspot.com/2011/01/point-sprites-as-spheres-in-opengl33.html
Demo source code : http://www.spacesimulator.net/wiki/index.php/3d_Engine_Projects