1 #version 140 // -*- mode: C -*-
2 // Defines emitted by gridrectst::init_gl at load:
3 // dimx, dimy: Grid size of the screen array
4 // dispx, dispy: Grid-cell (font) size
5 // vec4 colors[16]: Color palette; first non-bold, then bold
7 // offset_texpos, offset_addcolor, offset_grayscale, offset_cf, offset_cbr:
8 // offsets of the corresponding graphicst arrays in data
11 uniform usamplerBuffer data;
12 uniform samplerBuffer coords;
13 uniform isamplerBuffer fontmap;
15 uniform uint frame; // Counts up from 0
20 flat out vec4 frontColor;
21 flat out vec4 backColor;
22 smooth out vec2 texCoords;
25 int tile = gl_VertexID / 6;
26 int offset_tile = tile * 4;
28 int ch = int(texelFetch(data, offset_tile).a);
29 int fg = int(texelFetch(data, offset_tile+1).a);
30 int bg = int(texelFetch(data, offset_tile+2).a);
31 int bold = clamp(int(texelFetch(data, offset_tile+3).a), 0, 1);
34 uint texpos = texelFetch(data, offset_texpos + offset_tile).a;
35 texpos += texelFetch(data, offset_texpos + offset_tile + 1).a * 256u;
36 texpos += texelFetch(data, offset_texpos + offset_tile + 2).a * 65536u;
37 texpos += texelFetch(data, offset_texpos + offset_tile + 3).a * 16777216u;
38 uint addcolor = texelFetch(data, offset_addcolor + offset_tile).a;
39 uint grayscale = texelFetch(data, offset_grayscale + offset_tile).a;
40 uint cf = texelFetch(data, offset_cf + offset_tile).a;
41 uint cbr = texelFetch(data, offset_cbr + offset_tile).a;
45 if (texpos != 0u && ch != 0) {
46 tex_square = texelFetch(coords, int(texpos));
47 if (grayscale != 0u) {
48 frontColor = colors[int(cf + cbr * 8u)];
49 } else if (addcolor != 0u) {
50 frontColor = colors[fg + bold * 8];
55 tex_square = texelFetch(coords, texelFetch(fontmap, ch).a);
56 frontColor = colors[fg + bold * 8];
59 vec4 tex_square = texelFetch(coords, texelFetch(fontmap, ch).a);
60 frontColor = colors[fg + bold * 8];
63 vec2 coords[6] = vec2[](tex_square.sq, tex_square.tq, tex_square.tp,
64 tex_square.sq, tex_square.tp, tex_square.sp);
65 texCoords = coords[gl_VertexID % 6];
67 gl_Position = gl_Vertex;
68 backColor = colors[bg];