28 lines
583 B
GLSL
28 lines
583 B
GLSL
#version 410
|
|
|
|
/* Viewport width and height */
|
|
uniform ivec2 viewport_size;
|
|
/* Position of lower left corner of glyph */
|
|
uniform ivec2 position;
|
|
|
|
/* Vertex coordinates: x, y, s, t */
|
|
layout(location = 0) in vec4 coords;
|
|
|
|
/* Output texture coordinate: s, t */
|
|
out vec2 texture_coord_v;
|
|
|
|
/**
|
|
* 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.xy), 0, 1);
|
|
texture_coord_v = coords.zw;
|
|
}
|