#version 330 core

in vec2 v_uv;
flat in int v_color;

out vec4 FragColor;

uniform sampler2D u_texture;

vec4 color_from_int(int c) {
    return vec4(
        float((c >> 24) & 0xff) / 255.0,
        float((c >> 16) & 0xff) / 255.0,
        float((c >>  8) & 0xff) / 255.0,
        float((c >>  0) & 0xff) / 255.0
    );
}

void main() {
    vec4 color = color_from_int(v_color);
    FragColor = texture(u_texture, v_uv) * color;
}
