Search code examples
openglglslopengl-3

How do point sprites work when using different versions of GLSL/OpenGL?


As I understand it, gl_PointCoord is always available in the fragment shader in OpenGL 3 when rendering points; but, on the other hand, the GLSL 1.20 specification says that it is only available when "point sprites are enabled" (which I assume means after a call to glEnable(GL_POINT_SPRITE)).

Seeing as how those two statements conflict, and GL_POINT_SPRITE is not available in OpenGL 3, when is gl_PointCoord actually available? Does it depend on the #version directive, or on the GL profile one has obtained, or what?

Further, how does this interact with the point shape? As far as I understand it, points are rendered as squares when MSAA is turned off, and as circles when MSAA is turned on. When GL_POINT_SPRITE is available, they seem always to be rendered as squares when it is enabled, quite simply, but how would one control this properly in OpenGL 3? Is one supposed to simply turn multisampling off around point rendering calls when one wants them square?


Solution

  • gl_PointCoord is always "available" (filled with meaningful values) for GL_POINT primitives in core OpenGL. In compatibility profiles or an implementation that does not provide GLSL 130, you will have to enable GL_POINT_SPRITE.