Ensure OS windows have both buffers cleared after a resize/on first render
This commit is contained in:
parent
259dcf376c
commit
86e33f739c
@ -601,6 +601,7 @@ render(double now) {
|
||||
if (!w->num_tabs || !should_os_window_be_rendered(w)) continue;
|
||||
make_os_window_context_current(w);
|
||||
if (w->viewport_size_dirty) {
|
||||
w->clear_count = 0;
|
||||
update_surface_size(w->viewport_width, w->viewport_height, w->offscreen_texture_id);
|
||||
w->viewport_size_dirty = false;
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ gl_init() {
|
||||
|
||||
void
|
||||
update_surface_size(int w, int h, GLuint offscreen_texture_id) {
|
||||
glViewport(0, 0, w, h);
|
||||
if (offscreen_texture_id) {
|
||||
glBindTexture(GL_TEXTURE_2D, offscreen_texture_id);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
@ -365,6 +365,14 @@ draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWind
|
||||
|
||||
void
|
||||
draw_cells(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, OSWindow *os_window) {
|
||||
if (os_window->clear_count < 2) {
|
||||
os_window->clear_count++;
|
||||
#define C(shift) (((GLfloat)((OPT(background) >> shift) & 0xFF)) / 255.0f)
|
||||
glClearColor(C(16), C(8), C(0), os_window->is_semi_transparent ? OPT(background_opacity) : 1.0f);
|
||||
#undef C
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
cell_prepare_to_render(vao_idx, gvao_idx, screen, xstart, ystart, dx, dy);
|
||||
GLfloat w = (GLfloat)screen->columns * dx, h = (GLfloat)screen->lines * dy;
|
||||
#define SCALE(w, x) ((GLfloat)(os_window->viewport_##w) * (GLfloat)(x))
|
||||
|
||||
@ -104,6 +104,7 @@ typedef struct {
|
||||
bool has_pending_resizes;
|
||||
bool is_semi_transparent;
|
||||
uint32_t offscreen_texture_id;
|
||||
unsigned int clear_count;
|
||||
} OSWindow;
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user