emoon / rust_minifb

Cross platfrom window and framebuffer crate for Rust
MIT License
978 stars 92 forks source link

Annoying flickering when resizing on X11 #115

Open emoon opened 4 years ago

emoon commented 4 years ago

When resizing the window on Linux/X11 (Ubuntu, i3wm) there is lots of flickering. It would be nice to fix that

FloVanGH commented 4 years ago

On macOS during resize the screen is stretched and after resize stops, the screen flickers for a short time and the screens is drawn correct.

emoon commented 4 years ago

Yeah I will fix that when doing the mac fixes. It's now possible to set a scale mode with this https://github.com/emoon/rust_minifb/blob/dev/src/lib.rs#L152 (as part of WindowOptions) (only implemented on Linux/X11 in dev right now)

The main reason I added this is when screen size gets "forced" (i.e by window manager) and you have fixed sized buffer. Now the user can select how it should behave. If you always match the buffer size with the window size tho it shouldn't matter.

If you for example run the julia example (on x11 and dev branch) you can see it tries to keep aspect ratio

john01dav commented 4 years ago

I tried to set a scale option on Linux + X11 and it doesn't work (both stretch and upper left) When the window is resized, it instantly turns black. Of course, it's not that hard to redraw a new buffer when the window resizes, but that produces significant flickering. This flickering isn't just an aesthetic issue either — I suspect that it can cause seizures in some people (I don't know for sure, but I've seen seizure warnings on similar things before). If you're not at risk of seizures, see the attached file for what I'm referring to. flashy-bug.zip

emoon commented 4 years ago

@john01dav I'm not sure what you are trying to comment on. The issue (like stated on the top) is that the is lots of flickering when resizing under x11 which is currently a known issue. The scale option should work fine. (see the Julia example) but it will still flicker if you resize the window.

john01dav commented 4 years ago

@emoon I was making two points: 1) The known bug of flickering is more than an aesthetic issue (see my previous comment for details), which may be relevant to prioritizing if/when it is fixed. 2) Resizing doesn't work. After reading what you said, I realized that I misunderstood what resizing was for, so point #2 is wrong, but point #1 still stands.