Migrate the borders program

This commit is contained in:
Kovid Goyal
2017-09-11 15:39:29 +05:30
parent 5905216f96
commit 2a24199c90
6 changed files with 155 additions and 115 deletions

View File

@@ -1,7 +1,7 @@
#version GLSL_VERSION
uniform vec3 colors[3];
uniform uvec2 viewport;
in uvec4 rect; // left, top, right, bottom
in uint rect_color;
out vec3 color;
// indices into the rect vector
@@ -17,10 +17,16 @@ const uvec2 pos_map[] = uvec2[4](
uvec2(LEFT, TOP)
);
float to_opengl(uint val, uint sz) { return -1.0 + 2.0 * (float(val) / float(sz)); }
float to_opengl(uint val, uint sz) {
return -1.0 + 2.0 * (float(val) / float(sz));
}
float to_color(uint c) {
return float(c & uint(0xff)) / 255.0;
}
void main() {
uvec2 pos = pos_map[gl_VertexID];
gl_Position = vec4(to_opengl(rect[pos.x], viewport.x), to_opengl(rect[pos.y], viewport.y), 0, 1);
color = vec3(1, 0, 0);
color = vec3(to_color(rect_color >> 16), to_color(rect_color >> 8), to_color(rect_color));
}