Skip to content

Commit

Permalink
Pass ScreenDescriptor to egui_wgpu::CallbackTrait::prepare (emilk…
Browse files Browse the repository at this point in the history
…#3960)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

`glyphon` requires the screen resolution during the `prepare` stage, and
passing that to the callback's `prepare` function seems pretty trivial.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
2 people authored and hacknus committed Oct 30, 2024
1 parent 4353999 commit 9334ab5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/egui-wgpu/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub trait CallbackTrait: Send + Sync {
&self,
_device: &wgpu::Device,
_queue: &wgpu::Queue,
_screen_descriptor: &ScreenDescriptor,
_egui_encoder: &mut wgpu::CommandEncoder,
_callback_resources: &mut CallbackResources,
) -> Vec<wgpu::CommandBuffer> {
Expand Down Expand Up @@ -890,6 +891,7 @@ impl Renderer {
user_cmd_bufs.extend(callback.prepare(
device,
queue,
screen_descriptor,
encoder,
&mut self.callback_resources,
));
Expand Down
3 changes: 2 additions & 1 deletion crates/egui_demo_app/src/apps/custom3d_wgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::num::NonZeroU64;

use eframe::{
egui_wgpu::wgpu::util::DeviceExt,
egui_wgpu::{self, wgpu},
egui_wgpu::{self, renderer::ScreenDescriptor, wgpu},
};

pub struct Custom3d {
Expand Down Expand Up @@ -148,6 +148,7 @@ impl egui_wgpu::CallbackTrait for CustomTriangleCallback {
&self,
device: &wgpu::Device,
queue: &wgpu::Queue,
_screen_descriptor: &ScreenDescriptor,
_egui_encoder: &mut wgpu::CommandEncoder,
resources: &mut egui_wgpu::CallbackResources,
) -> Vec<wgpu::CommandBuffer> {
Expand Down

0 comments on commit 9334ab5

Please sign in to comment.