You can use point sprites to emulate this. Just turn on dot sprites and you get a special variable gl_PointCoord , which you can read in the fragment shader. This gives you the coordinates of the fragment in the square of the current point. You can simply use them to read a texture containing a circle (the pixels in the circle are not 0) and then discard each fragment whose texture value is 0:
if(texture2d(circle, gl_PointCoord).r < 0.1) discard;
EDIT: Or you can do it without texture, due to latency of access to the texture for computational complexity and just estimating the circle equation:
if(length(gl_PointCoord-vec2(0.5)) > 0.5) discard;
This can be further optimized by resetting the square root (used in the length function) and comparing with the square radius:
vec2 pt = gl_PointCoord - vec2(0.5); if(pt.x*pt.x+pt.y*pt.y > 0.25) discard;
But perhaps the built-in length function is even faster than this, optimized for calculating the length and can be implemented directly in hardware.
source share