Skip to content

Commit

Permalink
Update glow_integration.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Aug 31, 2024
1 parent 917ff38 commit f9f7dce
Showing 1 changed file with 2 additions and 41 deletions.
43 changes: 2 additions & 41 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,44 +552,6 @@ impl GlowWinitRunning {
(raw_input, viewport_ui_cb)
};

let clear_color = self
.app
.clear_color(&self.integration.egui_ctx.style().visuals);

let has_many_viewports = self.glutin.borrow().viewports.len() > 1;
let clear_before_update = !has_many_viewports; // HACK: for some reason, an early clear doesn't "take" on Mac with multiple viewports.

if clear_before_update {
// clear before we call update, so users can paint between clear-color and egui windows:

let mut glutin = self.glutin.borrow_mut();
let GlutinWindowContext {
viewports,
current_gl_context,
not_current_gl_context,
..
} = &mut *glutin;
let viewport = &viewports[&viewport_id];
let Some(window) = viewport.window.as_ref() else {
return Ok(EventResult::Wait);
};
let Some(gl_surface) = viewport.gl_surface.as_ref() else {
return Ok(EventResult::Wait);
};

let screen_size_in_pixels: [u32; 2] = window.inner_size().into();

{
frame_timer.pause();
change_gl_context(current_gl_context, not_current_gl_context, gl_surface);
frame_timer.resume();
}

self.painter
.borrow()
.clear(screen_size_in_pixels, clear_color);
}

// ------------------------------------------------------------
// The update function, which could call immediate viewports,
// so make sure we don't hold any locks here required by the immediate viewports rendeer.
Expand Down Expand Up @@ -649,10 +611,9 @@ impl GlowWinitRunning {
}

let screen_size_in_pixels: [u32; 2] = window.inner_size().into();
let clear_color = app.clear_color(&integration.egui_ctx.style().visuals);

if !clear_before_update {
painter.clear(screen_size_in_pixels, clear_color);
}
painter.clear(screen_size_in_pixels, clear_color);

painter.paint_and_update_textures(
screen_size_in_pixels,
Expand Down

0 comments on commit f9f7dce

Please sign in to comment.