-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pixels
panics when using egui
#351
Comments
The code in question might need to be shared to get a proper diagnosis. But in general, this kind of thing can happen when your pixel buffer is larger than the window surface. (I'm not certain if this requirement is documented properly? We could also add assertions in various places to help users troubleshoot these issues.) The pixel buffer size is set with The surface size is set with pixels/examples/minimal-egui/src/main.rs Lines 73 to 81 in 96eef39
Also note that the initial window size is passed to the constructor via the pixels/examples/minimal-egui/src/main.rs Lines 43 to 46 in 96eef39
Together, these keep the pixels/examples/minimal-egui/src/main.rs Lines 34 to 39 in 96eef39
Changing the library to allow a surface size smaller than the pixel buffer is probably possible, but as you described yourself, it would be undesirable! |
Both the window and the screen descriptor are initially created using 1024x768, I don't know why would this go wrong. Here's me creating the UI handler (Basically where all the UI stuff is done): pub fn new(
event_loop: &EventLoopWindowTarget<()>,
scale_factor: f32,
pixels: &pixels::Pixels,
) -> Self {
let max_texture_size = pixels.device().limits().max_texture_dimension_2d as usize;
let ctx = Context::default();
let mut state = egui_winit::State::new(event_loop);
state.set_max_texture_side(max_texture_size);
state.set_pixels_per_point(scale_factor);
let screen_descriptor = ScreenDescriptor {
size_in_pixels: [WINDOW_WIDTH as u32, WINDOW_HEIGHT as u32],
pixels_per_point: scale_factor,
};
let renderer = Renderer::new(pixels.device(), pixels.render_texture_format(), None, 1);
let textures = TexturesDelta::default();
Self {
ctx,
ui_state: state,
screen_descriptor,
renderer,
paint_jobs: Vec::new(),
textures,
panels_shown: true,
}
} And here's the resize event being handled: WindowEvent::Resized(p) => {
window.set_title(&format!("({}x{})", p.width, p.height));
// Resize pixels basically
graphics_mgr.resize(p.width, p.height);
// Then resize the UI
ui.resize(p.width, p.height);
}, |
The egui screen descriptor size is being initialized from constants in the sample code, but it should be initialized to match the default window size. Are you sure the constants are correct? The |
But isn't this the size I create the window with? let window = WindowBuilder::new()
.with_inner_size(LogicalSize::new(WINDOW_WIDTH, WINDOW_HEIGHT))
.with_max_inner_size(LogicalSize::new(8192, 8192))
.with_min_inner_size(LogicalSize::new(320, 240))
.with_window_icon(Some(
Icon::from_rgba(img.into_vec(), icon_width, icon_height).unwrap(),
))
.with_transparent(true)
.build(&event_loop)
.unwrap_or_else(|e| {
log::error!("Unable to create window: {}", e.to_string());
abort()
}); |
I ended up switching to ImGui, seems to work fine for now. I'll leave the issue open in case someone else runs into the same issue. |
Not necessarily! The pixels/examples/minimal-egui/src/main.rs Lines 43 to 53 in 96eef39
I think your code has probably diverged too much from the example reference, which is why it doesn't work. |
For some reason, when I simply try to create a UI using
egui
, I get this panic:The examples work fine, but this doesn't, although I basically copied half of the code from the examples.
If I reduce the size of the window in the screen descriptor to 256x192 (As the error seems to want me to do), it works, but then only that part of the window is actually used, the rest is left over.
The text was updated successfully, but these errors were encountered: