macroquad icon indicating copy to clipboard operation
macroquad copied to clipboard

_ScreenTexture isn't checked properly

Open Rushmore75 opened this issue 7 months ago • 2 comments

In this file: https://github.com/not-fl3/macroquad/blob/master/src/quad_gl.rs#L640 macroquad "checks" if _ScreenTexture is present in the file, not actually if it's defined or not, this causing a bug where I have a shader as follows:

#version 140
in lowp vec4 color;
in lowp vec2 uv;

// Set by macroquad
uniform sampler2D Texture;
// uniform sampler2D _ScreenTexture;

void main() {
    gl_FragColor = color * texture2D(Texture, uv) ;
}

Causing the _ScreenTexture to be applied erroneously.

This is tested by commenting out 640 and forcibly setting wants_screen_texture to false, fixing the bug.

I will try to make a PR to fix this

Rushmore75 avatar May 10 '25 00:05 Rushmore75

Not really seeing any metadata output from the shader compiler that could give us a hint if _ScreenTexture was commented or not, since the shader compiler looks to be external

IDK if you'd want to write your own parser? Since /* ... */ and // ... are valid comments in glsl

(https://www.opengl.org/sdk/docs/tutorials/TyphoonLabs/Chapter_2.pdf page 4)

Rushmore75 avatar May 10 '25 01:05 Rushmore75

Maybe glGetUniformLocation will do the trick? It would be quite a lot of platform(opengl/metal) specific code and I am not sure if it would be worth it.

not-fl3 avatar May 10 '25 08:05 not-fl3