add a rectangle shader

This commit is contained in:
josh committed 2016-09-13 22:19:47 -04:00
1 parent 6d8c8e76a9
commit c852e9991b
6 files changed
+130

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
#version 130
/* Color */
uniform vec4 color;
out vec4 frag_color;
void main(void)
{
frag_color = color;
}
+25
View File
@@ -0,0 +1,25 @@
#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;
/**
* 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);
}