[[vertex]]

in vec4 pos;
out vec2 uv;

void main()
{
    gl_Position = pos;
    uv = pos.xy * 0.5 + 0.5;
}

[[fragment]]

#include "include/ext-fb-fetch.glsl"

uniform sampler2D tex_bg;
uniform mediump vec4 col;

in highp vec2 uv;
#if defined(GL_EXT_shader_framebuffer_fetch)
    inout highp vec4 frag;
#else
    out highp vec4 frag;
#endif

void main()
{
    // sample from the background
#if defined(GL_EXT_shader_framebuffer_fetch)
    highp vec4 bg = frag;
#elif defined(GL_ARM_shader_framebuffer_fetch)
    highp vec4 bg = gl_LastFragColorARM;
#else
    highp vec4 bg = texture(tex_bg, uv);
#endif
    frag = bg.a == 0.0 ? vec4(col.rgb, 0.0) : bg;
}
