luminance-rs
luminance-rs copied to clipboard
luminance-glutin doesn't resize correctly under Wayland
- What I did: Ran the following code in Sway
use anyhow::Context as _;
use glutin::{
event::{Event, WindowEvent},
event_loop::ControlFlow,
};
use luminance_front::context::GraphicsContext;
use luminance_glutin::GlutinSurface;
fn main() -> anyhow::Result<()> {
let (mut surface, event_loop) = GlutinSurface::new_gl33_from_builders(
|_, window_builder| {
window_builder
.with_resizable(true)
.with_inner_size(glutin::dpi::LogicalSize::new(400, 400_u16))
},
|_, context_builder| context_builder,
)?;
surface.ctx.window().set_visible(true);
let mut on_event = move |event: Event<()>,
control_flow: &mut ControlFlow|
-> anyhow::Result<()> {
match event {
Event::NewEvents(..) => {
surface.ctx.window().request_redraw();
}
Event::WindowEvent { event, .. } => match event {
WindowEvent::Resized(size) => {
dbg!(size);
surface
.ctx
.window()
.set_inner_size(size);
}
WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit;
}
_ => {}
},
Event::RedrawRequested(..) => {
draw(&mut surface).context("Failed to render")?;
surface.swap_buffers();
}
_ => {}
}
Ok(())
};
event_loop.run(move |event, _, control_flow| {
match on_event(event, control_flow).context("Failed to process event") {
Ok(_) => {}
Err(e) => {
eprintln!("Error: {:?}", e);
std::process::exit(1);
}
}
});
}
fn draw(surface: &mut GlutinSurface) -> anyhow::Result<()> {
let back_buffer = surface.back_buffer()?;
let mut pipeline_gate = surface.new_pipeline_gate();
use luminance_front::pipeline::PipelineState;
pipeline_gate
.pipeline(
&back_buffer,
&PipelineState::new(),
|_, _| anyhow::Result::<()>::Ok(()),
)
.into_result()?;
Ok(())
}
Dependencies:
anyhow = "1.0.31"
glutin = "0.28"
luminance = "0.46"
luminance-front = "0.6"
luminance-derive = "0.9"
luminance-gl = "0.19"
luminance-glutin = "0.14"
- What I expected to happen: A window, completely filled with black, even after resizing.
- What happened instead: A transparent window with a 400x400 black square in its center.
surface.back_buffer()?.size()returns the correct dimensions of the window, but it's not actually rendering onto the entire window, only the 400x400 area in the middle. It looks really wonky when I make the window smaller than that, too, with the square sticking out from the window borders. On X11 the same code works as expected.