diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index b910a8820..963eb8012 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -1034,6 +1034,11 @@ mod glow_integration { ); let glutin = &mut *glutin.write(); + let screen_size_in_pixels: [u32; 2] = + win.inner_size().into(); + + let clipped_primitives = egui_ctx.tessellate(output.shapes); + glutin.current_gl_context = Some( glutin .current_gl_context @@ -1045,8 +1050,14 @@ mod glow_integration { .unwrap(), ); - let screen_size_in_pixels: [u32; 2] = - win.inner_size().into(); + if !window + .gl_surface + .as_ref() + .unwrap() + .is_current(glutin.current_gl_context.as_ref().unwrap()) + { + log::error!("egui::create_viewport_sync with title: `{}` is not created in main thread, try to use wgpu!", window.builder.title); + } egui_glow::painter::clear( &_gl, @@ -1054,8 +1065,6 @@ mod glow_integration { [0.0, 0.0, 0.0, 0.0], ); - let clipped_primitives = egui_ctx.tessellate(output.shapes); - _painter.write().paint_and_update_textures( screen_size_in_pixels, egui_ctx.pixels_per_point(), diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 1394e5457..9f2e8eaa8 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -271,8 +271,7 @@ impl ContextImpl { .memory .new_pixels_per_viewport .get(&viewport_id) - .map(|pixels| *pixels != new_pixels_per_point) - .unwrap_or(true) + .map_or(true, |pixels| *pixels != new_pixels_per_point) { new_raw_input.pixels_per_point = Some(new_pixels_per_point); self.memory diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index b835b88e5..3a986fde0 100644 --- a/examples/hello_world_par/Cargo.toml +++ b/examples/hello_world_par/Cargo.toml @@ -12,7 +12,7 @@ publish = false eframe = { path = "../../crates/eframe", default-features = false, features = [ # accesskit struggles with threading "default_fonts", - "glow", - # "wgpu", + "wgpu", + "x11" ] } env_logger = "0.10" diff --git a/examples/hello_world_par/src/main.rs b/examples/hello_world_par/src/main.rs index 7475f8398..41eb51d93 100644 --- a/examples/hello_world_par/src/main.rs +++ b/examples/hello_world_par/src/main.rs @@ -136,9 +136,6 @@ impl eframe::App for MyApp { for (_handle, show_tx) in &self.threads { let _ = show_tx.send(ctx.clone()); - } - - for _ in 0..self.threads.len() { let _ = self.on_done_rc.recv(); } }