Implement interleaved drawing of cells
This commit is contained in:
parent
3f615666df
commit
e1650d5df7
@ -9,6 +9,9 @@ in vec3 foreground;
|
||||
in vec3 decoration_fg;
|
||||
#endif
|
||||
in vec3 background;
|
||||
#ifdef SPECIAL
|
||||
in vec4 special_bg;
|
||||
#endif
|
||||
|
||||
out vec4 final_color;
|
||||
|
||||
@ -27,13 +30,20 @@ void main() {
|
||||
vec3 decoration = blend(underline_alpha, underline, strike);
|
||||
vec3 combined_fg = blend(text_alpha, fg, decoration);
|
||||
float combined_alpha = max(max(underline_alpha, strike_alpha), text_alpha);
|
||||
|
||||
#ifdef ALL
|
||||
final_color = vec4(blend(combined_alpha, combined_fg, background), 1);
|
||||
#else
|
||||
final_color = vec4(combined_fg, combined_alpha);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SPECIAL
|
||||
final_color = special_bg;
|
||||
#else
|
||||
final_color = vec4(background, 1);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -24,6 +24,9 @@ out vec3 foreground;
|
||||
out vec3 decoration_fg;
|
||||
#endif
|
||||
out vec3 background;
|
||||
#ifdef SPECIAL
|
||||
out vec4 special_bg;
|
||||
#endif
|
||||
|
||||
const uvec2 pos_map[] = uvec2[4](
|
||||
uvec2(1, 0), // right, top
|
||||
@ -113,6 +116,7 @@ void main() {
|
||||
int fg_index = color_indices[(text_attrs >> 6) & REVERSE_MASK];
|
||||
int bg_index = color_indices[1 - fg_index];
|
||||
background = to_color(colors[bg_index], default_colors[bg_index]);
|
||||
|
||||
#if defined(FOREGROUND) || defined(ALL)
|
||||
// The character sprite being rendered
|
||||
sprite_pos = to_sprite_pos(pos, sprite_coords.x, sprite_coords.y, sprite_coords.z & SHORT_MASK);
|
||||
@ -131,13 +135,16 @@ void main() {
|
||||
cursor = is_cursor(c, r);
|
||||
foreground = choose_color(cursor, background, foreground);
|
||||
decoration_fg = choose_color(cursor, background, decoration_fg);
|
||||
#if defined(SPECIAL) || defined(ALL)
|
||||
#ifdef SPECIAL
|
||||
cursor = is_cursor(c, r);
|
||||
#endif
|
||||
|
||||
#if defined(ALL)
|
||||
// Selection and cursor
|
||||
background = choose_color(is_selected, color_to_vec(highlight_bg), background);
|
||||
background = choose_color(cursor, color_to_vec(cursor_color), background);
|
||||
#endif
|
||||
#elif defined(SPECIAL)
|
||||
cursor = is_cursor(c, r);
|
||||
background = choose_color(is_selected, color_to_vec(highlight_bg), background);
|
||||
background = choose_color(cursor, color_to_vec(cursor_color), background);
|
||||
special_bg = vec4(background, max(cursor, is_selected));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -300,10 +300,21 @@ draw_all_cells(Screen *screen) {
|
||||
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); check_gl();
|
||||
}
|
||||
|
||||
static void
|
||||
draw_cells_interleaved(Screen *screen) {
|
||||
bind_program(CELL_BACKGROUND_PROGRAM);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); check_gl();
|
||||
bind_program(CELL_SPECIAL_PROGRAM);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); check_gl();
|
||||
bind_program(CELL_FOREGROUND_PROGRAM);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); check_gl();
|
||||
}
|
||||
|
||||
static void
|
||||
draw_cells_impl(ssize_t vao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, CursorRenderInfo *cursor) {
|
||||
cell_prepare_to_render(vao_idx, screen, xstart, ystart, dx, dy, cursor);
|
||||
draw_all_cells(screen);
|
||||
if (false) draw_cells_interleaved(screen);
|
||||
else draw_all_cells(screen);
|
||||
|
||||
}
|
||||
// }}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user