emoon / rust_minifb

Cross platfrom window and framebuffer crate for Rust
MIT License
1.01k stars 97 forks source link

On Windows, buffers larger than the window cause weird artifacts and look horrible #221

Closed LoganDark closed 3 years ago

LoganDark commented 3 years ago

At least on Windows, displaying a buffer larger than the size of the window causes weird artifacts.

My ray tracer is a good example of this, and is how the bug was discovered.

At 1x resolution:

image

At 2x resolution:

image

My friends with real Windows machines originally reported this bug to me, then I confirmed that it also happens in Wine, so I think the problem is minifb.

LoganDark commented 3 years ago

Here are some gifs

Bug:

raytracerbugwindows

Not bug:

raytracernotbugwindows

The only difference is the resolution of the framebuffer - no color calculation is affected by resolution in my code, in fact nothing is except for the amount of rays that are put out.

emoon commented 3 years ago

Exactly how do you send this larger than window buffer to minifb?

LoganDark commented 3 years ago

@emoon by using update_with_buffer ... ??? By "larger than the window" I mean in terms of resolution.

It's exactly the same as sending a buffer that's the same size as the window, or smaller than the window.

emoon commented 3 years ago

ok, I will have to investigate it. You can workaround the issue by scaling it manual (which you may or may not want to do anyway if you want super-sampled downscaling) minifb on will only scale with nearest filtering.

LoganDark commented 3 years ago

And you can also make it better by adding a function for me to query DPI scaling (since I only multiply the resolution by 2 to support high DPI on macOS, but then it causes bug on windows -_-)

emoon commented 3 years ago

temporary you can always check if you are running on macOS or Windows.

LoganDark commented 3 years ago

🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮 🤮

emoon commented 3 years ago

Hey, I wrote temporary above.

LoganDark commented 3 years ago

I'd rather wait for a fix is what I mean lol

emoon commented 3 years ago

Also, if you are in such hurry you can add it yourself.

LoganDark commented 3 years ago

Sorry, I did not mean to imply that I was in any sort of hurry, but you're not being very helpful by telling me to go do it myself.

Like I said, I'm more than happy to wait for a fix, apologies if anything I said came off the wrong way

emoon commented 3 years ago

I said if you want super-sampled down scaling (i.e anti-aliasing) you would have to do yourself (as minifb doesn't support it) regular scaling should work, but I don't think I have tested with buffer larger than the window.

emoon commented 3 years ago

I can try to get dpi_scale function added during the weekend.

LoganDark commented 3 years ago

Oh, you're misunderstanding me then. I'm taking advantage of the extra pixels on macOS, not trying to do antialiasing (I already have that). However somehow that causes minifb on Windows to flip out when the display doesn't have those extra pixels.

Apparently an entire Discord chat just agreed that the vomiting faces were exactly equivalent to "FUCK YOU WTF I NEED THIS FIXED RIGHT THIS MINUTE", so I'm sorry if it came off that way (that's really, really not what I meant). I was replying to the "check if the OS is macOS" hack specifically

emoon commented 3 years ago

Fair enough, yeah that is how I pretty much interpret it as well. Understood. I will get the scaling value return added soonish.

emoon commented 3 years ago

won't get around to implement it this weekend

LoganDark commented 3 years ago

Any progress on that dpi_scale function?

emoon commented 3 years ago

Sorry, not yet

emoon commented 3 years ago

Just FYI I have started to work on this but it's quite a lot of work.

emoon commented 3 years ago

Being tracked in #236