update opelgl background with button click...?

I’m working on a game with some simple Buttons, but behind them I draw an OpenGL dynamic background. How can I feed the location of my button to the fragment shader? I know how to get the screen coordinates of a View, but how do I translate them into something a shader would understand?

for instance …

a rectangle can be described as a min-max-aabb.

so passing two uniforms, vec2 min (lower left corner), vec2 max (upper right corner), should be sufficient.

if you compare numbers in the shader you need to have the right “space” available to you. you can stay in world-space (like you do with gl_Vertex calls) but then you need to pass the world-space position from the vertex-shader to fragment (if you need it in the fragment actually). if you use screen-space in fragment, you can just use gl_FragCoords. as long as the uniforms describing your buttons are in the same space - its all good.

Thanks, gl_FragCoord was what I needed!