diff --git a/CHANGELOG.md b/CHANGELOG.md index 43835a02..ca1fc513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui-w ## Unreleased ### Added ⭐ +* Added `NativeOptions::hardware_acceleration` to allow opting out of hardware acceleration for less power consumption ([#1681](https://github.com/emilk/egui/pull/1681)). * Added `*_released` & `*_clicked` methods for `PointerState` ([#1582](https://github.com/emilk/egui/pull/1582)). * Added `egui::hex_color!` to create `Color32`'s from hex strings under the `color-hex` feature ([#1596](https://github.com/emilk/egui/pull/1596)). * Optimized painting of filled circles (e.g. for scatter plots) by 10x or more ([#1616](https://github.com/emilk/egui/pull/1616)). diff --git a/eframe/src/epi.rs b/eframe/src/epi.rs index cf397331..d7cac24c 100644 --- a/eframe/src/epi.rs +++ b/eframe/src/epi.rs @@ -216,6 +216,11 @@ pub struct NativeOptions { /// `egui` doesn't need the stencil buffer, so the default value is 0. pub stencil_buffer: u8, + /// Use hardware acceleration if available. On macOS, this will possibly + /// use a dedicated GPU which will lead to higher power consumption. + /// The default value is `Some(true)` + pub hardware_acceleration: Option, + /// What rendering backend to use. pub renderer: Renderer, } @@ -238,6 +243,7 @@ impl Default for NativeOptions { multisampling: 0, depth_buffer: 0, stencil_buffer: 0, + hardware_acceleration: Some(true), renderer: Renderer::default(), } } diff --git a/eframe/src/native/epi_integration.rs b/eframe/src/native/epi_integration.rs index 349a34a4..69d665de 100644 --- a/eframe/src/native/epi_integration.rs +++ b/eframe/src/native/epi_integration.rs @@ -47,11 +47,12 @@ pub fn window_builder( max_window_size, resizable, transparent, - vsync: _, // used in `fn create_display` - multisampling: _, // used in `fn create_display` - depth_buffer: _, // used in `fn create_display` - stencil_buffer: _, // used in `fn create_display` - renderer: _, // used in `fn run_native` + vsync: _, // used in `fn create_display` + multisampling: _, // used in `fn create_display` + depth_buffer: _, // used in `fn create_display` + stencil_buffer: _, // used in `fn create_display` + hardware_acceleration: _, // used in `fn create_display` + renderer: _, // used in `fn run_native` } = native_options; let window_icon = icon_data.clone().and_then(load_icon); diff --git a/eframe/src/native/run.rs b/eframe/src/native/run.rs index 1cb36c74..606d85d1 100644 --- a/eframe/src/native/run.rs +++ b/eframe/src/native/run.rs @@ -17,6 +17,7 @@ fn create_display( crate::profile_function!(); let gl_window = unsafe { glutin::ContextBuilder::new() + .with_hardware_acceleration(native_options.hardware_acceleration) .with_depth_buffer(native_options.depth_buffer) .with_multisampling(native_options.multisampling) .with_srgb(true)