Skip to content

Commit

Permalink
Update minimal-egui to egui 0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobMillward committed Jan 1, 2024
1 parent c85a7ac commit f697e17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/minimal-egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ optimize = ["log/release_max_level_warn"]
default = ["optimize"]

[dependencies]
egui = "0.23"
egui-wgpu = "0.23"
egui-winit = { version = "0.23", default-features = false, features = ["links"] }
egui = "0.24"
egui-wgpu = "0.24"
egui-winit = { version = "0.24", default-features = false, features = ["links"] }
env_logger = "0.10"
error-iter = "0.4"
log = "0.4"
Expand Down
18 changes: 12 additions & 6 deletions examples/minimal-egui/src/gui.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use egui::{ClippedPrimitive, Context, TexturesDelta};
use egui::{ClippedPrimitive, Context, TexturesDelta, ViewportId};
use egui_wgpu::renderer::{Renderer, ScreenDescriptor};
use pixels::{wgpu, PixelsContext};
use winit::event_loop::EventLoopWindowTarget;
Expand Down Expand Up @@ -36,9 +36,13 @@ impl Framework {
let max_texture_size = pixels.device().limits().max_texture_dimension_2d as usize;

let egui_ctx = Context::default();
let mut egui_state = egui_winit::State::new(event_loop);
egui_state.set_max_texture_side(max_texture_size);
egui_state.set_pixels_per_point(scale_factor);
let egui_state = egui_winit::State::new(
ViewportId::ROOT,
event_loop,
Some(scale_factor),
Some(max_texture_size),
);

let screen_descriptor = ScreenDescriptor {
size_in_pixels: [width, height],
pixels_per_point: scale_factor,
Expand All @@ -60,7 +64,7 @@ impl Framework {

/// Handle input events from the window manager.
pub(crate) fn handle_event(&mut self, event: &winit::event::WindowEvent) {
let _ = self.egui_state.on_event(&self.egui_ctx, event);
let _ = self.egui_state.on_window_event(&self.egui_ctx, event);
}

/// Resize egui.
Expand All @@ -87,7 +91,9 @@ impl Framework {
self.textures.append(output.textures_delta);
self.egui_state
.handle_platform_output(window, &self.egui_ctx, output.platform_output);
self.paint_jobs = self.egui_ctx.tessellate(output.shapes);
self.paint_jobs = self
.egui_ctx
.tessellate(output.shapes, self.screen_descriptor.pixels_per_point);
}

/// Render egui.
Expand Down

0 comments on commit f697e17

Please sign in to comment.