Update egui to 0.18 (#281)
* Update egui to 0.18 - Closes #278 * Bump MSRV to 1.60.0 for egui
This commit is contained in:
parent
adaa469ad9
commit
af821c9e49
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- 1.57.0
|
||||
- 1.60.0
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
@ -73,7 +73,7 @@ jobs:
|
|||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- 1.57.0
|
||||
- 1.60.0
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
|
1
MSRV.md
1
MSRV.md
|
@ -2,6 +2,7 @@
|
|||
|
||||
| `pixels` version | `rustc` version |
|
||||
|------------------|-----------------|
|
||||
| `0.10.0` | `1.60.0` |
|
||||
| `0.9.0` | `1.57.0` |
|
||||
| `0.8.0` | `1.52.0` |
|
||||
| `0.7.0` | `1.52.0` |
|
||||
|
|
|
@ -10,9 +10,9 @@ optimize = ["log/release_max_level_warn"]
|
|||
default = ["optimize"]
|
||||
|
||||
[dependencies]
|
||||
egui = "0.17"
|
||||
egui_wgpu_backend = "0.17"
|
||||
egui-winit = { version = "0.17", default-features = false, features = ["links"] }
|
||||
egui = "0.18"
|
||||
egui-wgpu = "0.18"
|
||||
egui-winit = { version = "0.18", default-features = false, features = ["links"] }
|
||||
env_logger = "0.9"
|
||||
log = "0.4"
|
||||
pixels = { path = "../.." }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use egui::{ClippedMesh, Context, TexturesDelta};
|
||||
use egui_wgpu_backend::{BackendError, RenderPass, ScreenDescriptor};
|
||||
use egui::{ClippedPrimitive, Context, TexturesDelta};
|
||||
use egui_wgpu::renderer::{RenderPass, ScreenDescriptor};
|
||||
use pixels::{wgpu, PixelsContext};
|
||||
use winit::window::Window;
|
||||
|
||||
|
@ -10,7 +10,7 @@ pub(crate) struct Framework {
|
|||
egui_state: egui_winit::State,
|
||||
screen_descriptor: ScreenDescriptor,
|
||||
rpass: RenderPass,
|
||||
paint_jobs: Vec<ClippedMesh>,
|
||||
paint_jobs: Vec<ClippedPrimitive>,
|
||||
textures: TexturesDelta,
|
||||
|
||||
// State for the GUI
|
||||
|
@ -31,9 +31,8 @@ impl Framework {
|
|||
let egui_ctx = Context::default();
|
||||
let egui_state = egui_winit::State::from_pixels_per_point(max_texture_size, scale_factor);
|
||||
let screen_descriptor = ScreenDescriptor {
|
||||
physical_width: width,
|
||||
physical_height: height,
|
||||
scale_factor,
|
||||
size_in_pixels: [width, height],
|
||||
pixels_per_point: scale_factor,
|
||||
};
|
||||
let rpass = RenderPass::new(pixels.device(), pixels.render_texture_format(), 1);
|
||||
let textures = TexturesDelta::default();
|
||||
|
@ -58,14 +57,13 @@ impl Framework {
|
|||
/// Resize egui.
|
||||
pub(crate) fn resize(&mut self, width: u32, height: u32) {
|
||||
if width > 0 && height > 0 {
|
||||
self.screen_descriptor.physical_width = width;
|
||||
self.screen_descriptor.physical_height = height;
|
||||
self.screen_descriptor.size_in_pixels = [width, height];
|
||||
}
|
||||
}
|
||||
|
||||
/// Update scaling factor.
|
||||
pub(crate) fn scale_factor(&mut self, scale_factor: f64) {
|
||||
self.screen_descriptor.scale_factor = scale_factor as f32;
|
||||
self.screen_descriptor.pixels_per_point = scale_factor as f32;
|
||||
}
|
||||
|
||||
/// Prepare egui.
|
||||
|
@ -89,10 +87,12 @@ impl Framework {
|
|||
encoder: &mut wgpu::CommandEncoder,
|
||||
render_target: &wgpu::TextureView,
|
||||
context: &PixelsContext,
|
||||
) -> Result<(), BackendError> {
|
||||
) {
|
||||
// Upload all resources to the GPU.
|
||||
for (id, image_delta) in &self.textures.set {
|
||||
self.rpass
|
||||
.add_textures(&context.device, &context.queue, &self.textures)?;
|
||||
.update_texture(&context.device, &context.queue, *id, image_delta);
|
||||
}
|
||||
self.rpass.update_buffers(
|
||||
&context.device,
|
||||
&context.queue,
|
||||
|
@ -107,11 +107,13 @@ impl Framework {
|
|||
&self.paint_jobs,
|
||||
&self.screen_descriptor,
|
||||
None,
|
||||
)?;
|
||||
);
|
||||
|
||||
// Cleanup
|
||||
let textures = std::mem::take(&mut self.textures);
|
||||
self.rpass.remove_textures(textures)
|
||||
for id in &textures.free {
|
||||
self.rpass.free_texture(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ fn main() -> Result<(), Error> {
|
|||
context.scaling_renderer.render(encoder, render_target);
|
||||
|
||||
// Render egui
|
||||
framework.render(encoder, render_target, context)?;
|
||||
framework.render(encoder, render_target, context);
|
||||
|
||||
Ok(())
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue