We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › glsl gl_PointSize not working (Solved)
Page Index Toggle Pages: 1
glsl gl_PointSize not working? (Solved) (Read 2074 times)
glsl gl_PointSize not working? (Solved)
Mar 18th, 2010, 7:01pm
 
I've been trying all night to get gl_PointSize to work with no luck.  The point size only seems to respond to gl.glPointSize(10);
Using  gl.glEnable(gl.GL_VERTEX_PROGRAM_POINT_SIZE);

Here is my vertex shader
void main() {
   //gl_Position = ftransform();
   gl_PointSize = 20.0;
}
Re: glsl gl_PointSize not working?
Reply #1 - Mar 19th, 2010, 7:35am
 
In experiments I did a while ago, different video cards have different limits to the point size. You can make them appear bigger on screen by playing with gl.glPointParameterfv(GL.GL_POINT_DISTANCE_ATTENUATION..... ) things, but that's some dark voodoo that I never got working properly.
Re: glsl gl_PointSize not working?
Reply #2 - Mar 19th, 2010, 9:15am
 
Ya, I tried GL.GL_POINT_DISTANCE_ATTENUATION, but kept getting a weird flickering.  I also couldn't quite figure out the quadratic, no one bothers to explain what's happening.
Re: glsl gl_PointSize not working?
Reply #3 - Mar 19th, 2010, 12:37pm
 
I think I've got it...  Grin
PDE
Code:

gl.glEnable(GL.GL_POINT_SPRITE);
gl.glEnable(gl.GL_VERTEX_PROGRAM_POINT_SIZE);
shader.startShader();
gl.glUniform1f(shader.getUniformLocation("pointSize"), 100.0);
gl.glTexEnvi(GL.GL_POINT_SPRITE, GL.GL_COORD_REPLACE, GL.GL_TRUE);
gl.glColor3f(1, 1, 1);
ringImg.enable();
ringImg.bind();
gl.glBindBuffer( GL.GL_ARRAY_BUFFER,  nodes_vbo[0]);
gl.glVertexPointer(3,GL.GL_FLOAT,0,0);
gl.glBindBuffer( GL.GL_ELEMENT_ARRAY_BUFFER, nelements_vbo[0] );
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glDrawElements( GL.GL_POINTS, vnodelength, GL.GL_UNSIGNED_INT, 0 );
...

Vertex Shader
Code:
uniform float pointSize;
void main() {
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
   vec4 mod = vec4( gl_ModelViewMatrix * gl_Vertex );
   gl_PointSize = 200.0 * pointSize/ -mod.z ;
   gl_FrontColor = gl_Color;
}
Page Index Toggle Pages: 1