PDA

View Full Version : gl_PointCoord examples would be great



OceanJeff40
04-17-2017, 09:34 AM
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

GClements
04-17-2017, 01:28 PM
Core profile or compatibility profile? In the compatibility profile, you'll need glEnable(GL_POINT_SPRITE).

OceanJeff40
04-17-2017, 04:21 PM
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

OceanJeff40
04-17-2017, 05:41 PM
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

GClements
04-18-2017, 08:28 AM
That appears to be a deprecated and removed feature as of 3.2??
Yes, which is why I asked

Core profile or compatibility profile?
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).

OceanJeff40
04-19-2017, 07:33 PM
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

GClements
04-19-2017, 07:53 PM
Not sure what you mean by all those profile options, or how to change those......

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).



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.

Have you tried glEnable(GL_POINT_SPRITE)?