shaders and GL_POINT_SPRITE_ARB

I am working on a project that uses point sprites as rendering primitives. I want to manipulate output using vertex and fragment programs and can’t seem to get them working together. Using Cg lib and compilation goes without errors. Here is my code, so please tell me what I am doing wrong.


Gl.glEnable(Gl.GL_BLEND);
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); //set the blend function				

float[] mat = new float[16];

Gl.glPointSize(60);

float[] quadratic =  { 1, 0f, 0.01f };			
Gl.glPointParameterfvARB(Gl.GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic);
Gl.glPointParameterfARB(Gl.GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f);

float maxSize = 0.0f;
Gl.glGetFloatv(Gl.GL_POINT_SIZE_MAX_ARB, out maxSize);
Gl.glPointParameterfARB(Gl.GL_POINT_SIZE_MIN_ARB, 1.0f);
Gl.glPointParameterfARB(Gl.GL_POINT_SIZE_MAX_ARB, maxSize);

Gl.glTexEnvf(Gl.GL_POINT_SPRITE_ARB, Gl.GL_COORD_REPLACE_ARB, Gl.GL_TRUE);					
Gl.glEnable(Gl.GL_POINT_SPRITE_ARB);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]);
			
Gl.glDepthMask(Gl.GL_FALSE);

// Track the combined model-view-projection matrix			
CgGl.cgGLSetStateMatrixParameter(m_CGparam_modelViewProj,
										CgGl.CG_GL_MODELVIEW_PROJECTION_MATRIX,
										CgGl.CG_GL_MATRIX_IDENTITY);
checkForCgError("setting state matrix parameter");
			
Gl.glGetFloatv(Gl.GL_MODELVIEW_MATRIX, mat);

Vector3f vRight = new Vector3f(mat[0], mat[4], mat[8]);
Vector3f vUp = new Vector3f(mat[1], mat[5], mat[9]);
Vector3f vCenter = new Vector3f(0.0f, 0.0f, 0.0f);

SetShaderParameters();
EnableShaders();

//render
Gl.glTranslatef(ViewerPosition.x, ViewerPosition.y, ViewerPosition.z - 100);
Gl.glColor3f(1, 1, 0);
Point3D centerPoint = new Point3D(25, -25, 0);


Gl.glBegin(Gl.GL_POINTS);
Gl.glVertex3f(centerPoint.x - 25, centerPoint.y - 25, 0);
Gl.glVertex3f(centerPoint.x + 25, centerPoint.y - 25, 0);
Gl.glVertex3f(centerPoint.x + 25, centerPoint.y + 25, 0);
Gl.glVertex3f(centerPoint.x - 25, centerPoint.y + 25, 0);
Gl.glEnd();

Gl.glPopMatrix();

//Gl.glCallList(lidarDisplList);
Gl.glDepthMask(Gl.GL_TRUE);

Gl.glDisable(Gl.GL_POINT_SPRITE_ARB);

DisableShaders();


shader load function - no errors


CgGl.cgGLBindProgram(m_CGp_vertexProgram);
			checkForCgError("binding vertex program");

			CgGl.cgGLEnableProfile(m_CG_vertexProfile);
			checkForCgError("enabling vertex profile");

			CgGl.cgGLBindProgram(m_CGp_fragmentProgram);
			checkForCgError("binding fragment program");

			CgGl.cgGLEnableProfile(m_CG_fragmentProfile);
			checkForCgError("enabling fragment profile");

shader disable function


		CgGl.cgGLDisableProfile(m_CG_fragmentProfile);
			checkForCgError("disabling fragment profile");

			CgGl.cgGLDisableProfile(m_CG_vertexProfile);
			checkForCgError("disabling fragment profile");

maybe I was a little to vague in description of the problem. When I run the program without enabling and disabling shaders the point sprite rendering works fine. An drawing normal points and with shaders enabled also works. It’s just when I try to mix them the application draws blank screen.

my mistake, sorry. shaders are working, I was just setting modelviewprojection matrix too early. I have a bigger problem now. All my points are rendered as normal points. Could be they are point sprites, but they are as small as normal points. Point distance attenuation is not working or something. Help?

You have to enable GL_VERTEX_PROGRAM_POINT_SIZE_ARB.

just figured this one out, thanks anyway