#version 330

uniform vec2 u_viewport;

in vec2 position;
in vec2 uv;
in int color;

out vec2 v_uv;
flat out int v_color;

vec2 from_pixel_pos(vec2 position, vec2 viewport) {
    return mix(vec2(-1.0, 1.0), vec2(1.0, -1.0), position / u_viewport);
}

void main() {
    gl_Position = vec4(from_pixel_pos(position, u_viewport), 0.0, 1.0);
    v_uv = uv;
    v_color = color;
}
