Skip to content

Commit

Permalink
Update egui from 0.23 to the newest 0.24 (#52)
Browse files Browse the repository at this point in the history
* Just updated egui alone.

* nightly formatting

* Fixed out of date swapchain crash for the examples.

* Updated egui 0.23 -> 0.24
  • Loading branch information
Letronix624 authored Nov 30, 2023
1 parent 50bd7f6 commit 9fe9ead
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ clipboard = ["egui-winit/clipboard"]

[dependencies]
ahash = "0.8.3"
egui = "0.23"
egui-winit = "0.23"
egui-winit = "0.24"
egui = "0.24"
image = "0.24.5"
winit = "0.28.2"
vulkano = "0.34"
vulkano-shaders = "0.34"

[dev-dependencies]
cgmath = "0.18.0"
egui_demo_lib = "0.23"
egui_demo_lib = "0.24"
vulkano-util = "0.34"
2 changes: 1 addition & 1 deletion examples/demo_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

use egui_winit_vulkano::{Gui, GuiConfig};
use egui_winit_vulkano::{egui, Gui, GuiConfig};
use vulkano::sync::{self, GpuFuture};
use vulkano_util::{
context::{VulkanoConfig, VulkanoContext},
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#![allow(clippy::eq_op)]

use egui::{ScrollArea, TextEdit, TextStyle};
use egui_winit_vulkano::{Gui, GuiConfig};
use egui_winit_vulkano::{egui, Gui, GuiConfig};
use vulkano::sync::{self, GpuFuture};
use vulkano_util::{
context::{VulkanoConfig, VulkanoContext},
Expand Down
2 changes: 1 addition & 1 deletion examples/multisample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
};

use egui::{epaint::Shadow, style::Margin, vec2, Align, Align2, Color32, Frame, Rounding, Window};
use egui_winit_vulkano::{Gui, GuiConfig};
use egui_winit_vulkano::{egui, Gui, GuiConfig};
use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{
Expand Down
2 changes: 1 addition & 1 deletion examples/paint_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use std::{convert::TryInto, sync::Arc};

use egui::{mutex::Mutex, vec2, PaintCallback, PaintCallbackInfo, Rgba, Sense};
use egui_winit_vulkano::{CallbackContext, CallbackFn, Gui, GuiConfig, RenderResources};
use egui_winit_vulkano::{egui, CallbackContext, CallbackFn, Gui, GuiConfig, RenderResources};
use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
memory::allocator::{AllocationCreateInfo, MemoryTypeFilter},
Expand Down
2 changes: 1 addition & 1 deletion examples/subpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
};

use egui::{epaint::Shadow, style::Margin, vec2, Align, Align2, Color32, Frame, Rounding, Window};
use egui_winit_vulkano::{Gui, GuiConfig};
use egui_winit_vulkano::{egui, Gui, GuiConfig};
use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{
Expand Down
2 changes: 1 addition & 1 deletion examples/wholesome/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use std::sync::Arc;

use egui::{load::SizedTexture, Context, ImageSource, Visuals};
use egui_winit_vulkano::{Gui, GuiConfig};
use egui_winit_vulkano::{egui, Gui, GuiConfig};
use vulkano::{
command_buffer::allocator::{
StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo,
Expand Down
34 changes: 24 additions & 10 deletions src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,15 @@ impl Gui {
let max_texture_side =
renderer.queue().device().physical_device().properties().max_image_array_layers
as usize;
let mut egui_winit = egui_winit::State::new(event_loop);
egui_winit.set_max_texture_side(max_texture_side);
egui_winit.set_pixels_per_point(surface_window(&surface).scale_factor() as f32);
let egui_ctx: egui::Context = Default::default();
let egui_winit = egui_winit::State::new(
egui_ctx.viewport_id(),
event_loop,
Some(surface_window(&surface).scale_factor() as f32),
Some(max_texture_side),
);
Gui {
egui_ctx: Default::default(),
egui_ctx,
egui_winit,
renderer,
surface,
Expand All @@ -134,6 +138,11 @@ impl Gui {
}
}

/// Returns the pixels per point of the window of this gui.
fn pixels_per_point(&self) -> f32 {
egui_winit::pixels_per_point(&self.egui_ctx, surface_window(&self.surface))
}

/// Returns a set of resources used to construct the render pipeline. These can be reused
/// to create additional pipelines and buffers to be rendered in a `PaintCallback`.
pub fn render_resources(&self) -> RenderResources {
Expand All @@ -148,7 +157,7 @@ impl Gui {
///
/// Note that egui uses `tab` to move focus between elements, so this will always return `true` for tabs.
pub fn update(&mut self, winit_event: &winit::event::WindowEvent<'_>) -> bool {
self.egui_winit.on_event(&self.egui_ctx, winit_event).consumed
self.egui_winit.on_window_event(&self.egui_ctx, winit_event).consumed
}

/// Begins Egui frame & determines what will be drawn later. This must be called before draw, and after `update` (winit event).
Expand Down Expand Up @@ -190,7 +199,7 @@ impl Gui {
self.renderer.draw_on_image(
&clipped_meshes,
&textures_delta,
self.egui_winit.pixels_per_point(),
self.pixels_per_point(),
before_future,
final_image,
)
Expand All @@ -215,7 +224,7 @@ impl Gui {
self.renderer.draw_on_subpass_image(
&clipped_meshes,
&textures_delta,
self.egui_winit.pixels_per_point(),
self.pixels_per_point(),
image_dimensions,
)
}
Expand All @@ -224,13 +233,18 @@ impl Gui {
self.end_frame();
let shapes = std::mem::take(&mut self.shapes);
let textures_delta = std::mem::take(&mut self.textures_delta);
let clipped_meshes = self.egui_ctx.tessellate(shapes);
let clipped_meshes = self.egui_ctx.tessellate(shapes, self.pixels_per_point());
(clipped_meshes, textures_delta)
}

fn end_frame(&mut self) {
let egui::FullOutput { platform_output, repaint_after: _r, textures_delta, shapes } =
self.egui_ctx.end_frame();
let egui::FullOutput {
platform_output,
textures_delta,
shapes,
pixels_per_point: _,
viewport_output: _,
} = self.egui_ctx.end_frame();

self.egui_winit.handle_platform_output(
surface_window(&self.surface),
Expand Down

0 comments on commit 9fe9ead

Please sign in to comment.