freetype2gl3/rect.v.glsl

32 lines
579 B
GLSL

#version 130
/* Viewport width and height */
uniform ivec2 viewport_size;
/* Position offset */
uniform ivec2 position;
/* Rectangle size */
uniform ivec2 size;
/* Vertex coordinates: x, y */
in vec2 coords;
/* Vertex color */
in vec4 color;
/* Interpolated color */
out vec4 i_color;
/**
* Map coordinates such that:
* (0 .. viewport_size.[xy]) => (-1.0 .. 1.0)
*/
vec2 map_to_screen(vec2 position)
{
return 2.0 * position / viewport_size - 1.0;
}
void main(void)
{
gl_Position = vec4(map_to_screen(vec2(position) + coords * size), 0, 1);
i_color = color;
}