glPointSize
Sets the diameter in pixels of points drawn with GL_POINTS (when the shader does not set it).
Signature
void glPointSize(GLfloat size);
How it works
A GL_POINTS draw makes one square of size × size pixels per vertex. The default, 1, is a single pixel and hard to see, so lessons that show vertices as points set it larger.
There are two sources for the size. If glEnable(GL_PROGRAM_POINT_SIZE) is on, the vertex shader writes gl_PointSize per vertex (for particles that shrink with distance). If it is off, this fixed value is used.
Parameters
Diameter in pixels, greater than 0. Default 1.
Tips & pitfalls
Points are squares; for round ones, discard fragments in the fragment shader where length(gl_PointCoord − 0.5) > 0.5.
The largest size depends on the GPU (GL_POINT_SIZE_RANGE).
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GL_INVALID_VALUE
- size is 0 or negative.
Example
1glPointSize(10.0f);
2glDrawArrays(GL_POINTS, 0, 3); // three visible dots