mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Allow redirecting rendering to a FBO
This commit is contained in:
12
kitty/gl.c
12
kitty/gl.c
@@ -119,6 +119,18 @@ free_framebuffer(GLuint *fb_id) {
|
|||||||
*fb_id = 0;
|
*fb_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLuint output_framebuffer = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
bind_framebuffer_for_output(unsigned fbid) {
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, fbid || output_framebuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_framebuffer_to_use_for_output(unsigned fbid) {
|
||||||
|
output_framebuffer = fbid;
|
||||||
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
GLsizei items[16][4];
|
GLsizei items[16][4];
|
||||||
size_t used;
|
size_t used;
|
||||||
|
|||||||
@@ -61,3 +61,5 @@ void save_viewport_using_top_left_origin(GLsizei x, GLsizei y, GLsizei width, GL
|
|||||||
void save_viewport_using_bottom_left_origin(GLsizei x, GLsizei y, GLsizei width, GLsizei height);
|
void save_viewport_using_bottom_left_origin(GLsizei x, GLsizei y, GLsizei width, GLsizei height);
|
||||||
void check_framebuffer_status_or_die(void);
|
void check_framebuffer_status_or_die(void);
|
||||||
void restore_viewport(void);
|
void restore_viewport(void);
|
||||||
|
void bind_framebuffer_for_output(unsigned fbid);
|
||||||
|
void set_framebuffer_to_use_for_output(unsigned fbid);
|
||||||
|
|||||||
@@ -673,12 +673,12 @@ ensure_layer_ready_to_render(const UIRenderData *ui, ScreenLayer *which) {
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, which->width, which->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, which->width, which->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, which->framebuffer_id);
|
bind_framebuffer_for_output(which->framebuffer_id);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, which->id, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, which->id, 0);
|
||||||
check_framebuffer_status_or_die();
|
if (global_state.debug_rendering) check_framebuffer_status_or_die();
|
||||||
needs_redraw = true;
|
needs_redraw = true;
|
||||||
}
|
}
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, which->framebuffer_id);
|
bind_framebuffer_for_output(which->framebuffer_id);
|
||||||
return needs_redraw;
|
return needs_redraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -979,7 +979,7 @@ update_screen_layers(UIRenderData *ui) {
|
|||||||
ui->has_under_fg = update_under_fg_layer(ui);
|
ui->has_under_fg = update_under_fg_layer(ui);
|
||||||
ui->has_over_fg = update_over_fg_layer(ui);
|
ui->has_over_fg = update_over_fg_layer(ui);
|
||||||
ui->has_ui = update_ui_layer(ui);
|
ui->has_ui = update_ui_layer(ui);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
bind_framebuffer_for_output(0);
|
||||||
restore_viewport();
|
restore_viewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user