glutin
glutin copied to clipboard
Screenbuffer does not resize on Mac
I want to toggle the aspect ratio between 16:9 and 9:16 at runtime. Everything works fine on app start, but there is something wrong with the Mac implementation of set_inner_size(). My framebuffers resize properly but the window's screenbuffer does not change size.
@Osspial recommended calling Glutin's resize() function but this produced a black screen.
Can you post the code that's calling resize
? It should work.
pub fn resize(&mut self, width: usize, height: usize) {
let logical_size = LogicalSize {
width: width as f64,
height: height as f64
};
self.windowed_context.window().set_inner_size(logical_size);
{ // hack to fix resize on mac
let physical_size = logical_size.to_physical(self.dpi as f64);
self.windowed_context.resize(physical_size);
}
}
Maybe it would work if it were called in the WindowEvent::Resized
handler?
Same behavior - black screen.
Resized(logical_size) => {
let physical_size = logical_size.to_physical(window.dpi as f64);
window.windowed_context.resize(physical_size);
}
Hmm. Not entirely sure what to do, then.
cc @vbogaevsky would you be able to look into this? Also, I'm going to move this issue over to Glutin, since it seems more likely to be a bug there.
Should probably call glViewport
to update the viewport.
Should probably call
glViewport
to update the viewport.
It's not a viewport issue.
Do you have an example I can test?
@goddessfreya here you go. This actually demonstrates a more general form of the bug. Simply resize the window with your mouse on mac. The red unit rectangle fills the screen on startup but the background is visible after window resize. It resembles a viewport issue, but I am setting the viewport properly
I have a similar issue. When I resize the window, the screen buffer is not changing. So the rendered image is getting distorted.
I have a similar issue. When I resize the window, the screen buffer is not changing. So the rendered image is getting distorted.
Oh, hold on, I fixed my problem. My case was that I forgot to call ContextWrapper::resize
on resizing event handlers.
It works well after calling this function correctly.
@AcrylicShrimp Would this also be resolved if glutin
had a helper function to handle winit
events? After all, glutin
heavily builds on top of winit
.
I'm (slowly) working on this for Android lifecycle support.
@MarijnS95 If you mean helper functions to handle window events in the glutin
, yes, it would maybe. But I'm not sure it's a good way to go. The main problem was that it's hard to know how to resize correctly. And I didn't even know existence of the resize
function on the ContextWrapper
. Adding a section on the docs for resizing with detailed description would be better.
No winit in glutin anymore.