gl_PointCoord examples would be great

Hey all,

I’m trying to play around with large points (32 by 32), yes, these are GL_POINTS, drawn with point size 32. First I want to experiment with Algorithmically drawing on these points in the fragment shader, and second I want to map textures onto these points (using the built-in variable gl_PointCoord in the fragment shader).

I’m not having any luck accessing the gl_PointCoord vector.

I’ve included the gl_PointCoord.s and gl_PointCoord.t in my shader, as color values, but nothing is the result… I also tried x and y.

I’ve tried googling some examples of using this built-in variable, but no luck so far.

Anybody have some examples that work, that I could see? Or anyone know of a bug/reason why these won’t work?

I’m trying to add to my videos on youtube that show how to program in OpenGL, here’s the shameless link:

https://www.youtube.com/channel/UCzx8alrxVELz5h1dfCdkdfg

Thanks guys, appreciate any help you can throw my way,

Jeff Cummings

Core profile or compatibility profile? In the compatibility profile, you’ll need glEnable(GL_POINT_SPRITE).

That appears to be a deprecated and removed feature as of 3.2??

https://www.opengl.org/discussion_boards/showthread.php/169317-GL_POINT_SPRITE-gone-in-3-2

Thanks, though,

Jeff

Currently, my fragment shader is this:

#version 450 core

out vec4 fColor;

void main()
{
fColor = vec4(gl_PointCoord, 1.0, 1.0);
}

And it just shows the points as blue 32x32 (since I’ve designated their size be 32).

Jeff

Yes, which is why I asked

In the compatibility profile, nothing has changed (that’s why it’s called the “compatibility” profile); you only get point sprites if you explicitly enable them.

Note that it’s the context profile which matters, not the profile specified in the shader. A shader using “450 core” will work in a compatibility profile (the reverse isn’t true), but gl_PointCoord won’t be set if point sprites aren’t enabled (either explicitly or because the version and profile force it).

Not sure what you mean by all those profile options, or how to change those…

But My points are displaying colors, what I’m looking for is to access the gl_PointCoord.s and gl_PointCoord.t, to apply to texture sampler, and turn the point color into a point sprite.

Thanks,
Jeff

Which tends to suggest that you’re using the compatibility profile; most toolkits will give you a compatibility-profile context unless you specifically request a core-profile context. And the compatibility profile doesn’t enable point sprites by default, regardless of version (it wouldn’t provide much compatibility if it did).

Have you tried glEnable(GL_POINT_SPRITE)?