GLSL: cccess to gl_PointCoord


#1

I’m practicing drawing programatic geometry using GLSL based off of the JUCE OpenGL demo. I’m trying to access gl_PointCoord in the fragment shader in order to create kind of sprite looking things from GL_POINTS that I’m drawing from a VBO. According to the documentation, gl_PointCoord.xy should correspond to the normalized position of each fragment within the point going from left to right. However it seems that the values are always set to zero when I try to use them. I did have to add #version 120 to the top of the fragment shader in order to get access to gl_PointCoord (otherwise it would spit an error), so I’m wondering if there’s something I need to do back on the JUCE side in order to “fill” this data. 

 

 


#2

I don't think this is a juce thing - AFAIK you should be able to do everything you need from the shader code, if the driver supports it.


#3

Thanks for the feedback and sorry for the trouble. Interestingly, I had to glEnable(0x8861) which corresponds to the missing enum GL_POINT_SPRITE. I didn't think that would/should work but it did. I don't understand enough about versions of OpenGL/GLSL to know why that was necessary. From reading around it seems that newer version of GL enable it by default, hence the missing enum. I cross-posted in reddit.com/r/opengl which is a great resource for anyone else needing graphics-specific help: 

https://www.reddit.com/r/opengl/comments/480u1r/help_gl_pointcoordxy_always_zero_in_fragment/