Hey all,

I'm new to OpenGL, and to this forum as well, and I appreciate everyone's kind support, this is a great community!

Anyways, I wanted to ask about these two built in input variables in the fragment shaders: gl_FragCoord and gl_PointCoord.

I have tried to play around with both of them several times, and I don't get anything from either of them. Here's my current fragment shader, and where gl_PointCoord is, I've tried using gl_FragCoord, just to get a vertical stripe on the points (which are size 35 in vertex shader, and they do properly display on-screen as 35x35 squares...!).

Vertex shader:

Code :
#version 330 core
layout (location = 0) in vec2 position;
layout (location = 1) in vec3 color;
 
out vec3 ourColor;
 
void main()
{
    gl_PointSize = 35.0f;
    gl_Position = vec4(position.x, position.y, 0.0f, 1.0f); 
    ourColor = color;
}

Fragment shader:

Code :
#version 330 core
in vec3 ourColor;
 
out vec4 color;
 
void main()
{
    if ( gl_FragCoord.x > 0.4 && gl_FragCoord.x < 0.6 )
    {
        color = vec4(0.0f,0.0f,1.0f,1.0f);
    } else {
        color = vec4(ourColor, 1.0f);
    }
}

I'm not trying to do anything meaningful, just wanting to experiment and get a feel for these variables, but they are proving to be quite the buggers to even work with them.... any ideas?

So if I use gl_PointCoord in the place of gl_FragCoord above, shouldn't that put a vertical stripe of blue on the squares themselves? and using the gl_FragCoord as I listed above, shouldn't that make a vertical column of blue squares like an overlay on the screen as the squares pass through that column on the screen? They are animated and bouncing around the screen, as I am using my fireworks demo for this small experimental project.

Thanks in advance,
Jeff
My YouTube channel for OpenGL Basics Tutorials