What is the range of gl_FragCoord

I did a test to the actual range of gl_FragCoord.xy, by using the following shader code and glReadPixels(0, 0, 1024, 1024, GL_RED, GL_FLOAT, xxx) to get the output of the shader from my framebuffer object, and the FBO had attached a texture which's internal format is GL_R32F.

out highp vec4 Output;

void main()
{
    Output = vec4(gl_FragCoord.xy, 0.0, 1.0);
}

The actual result is: gl_FragCoord.xy is in the range [0.5, 1023.5], not [0.0, 1023.0].


gl_FragCoord coordinates are indexed starting from 0.

The expression gl_FragCoord.x - 5 would result in a value in the range [-5, (width - 5) - 1]