DCurrent / openbor

OpenBOR is the ultimate 2D side scrolling engine for beat em' ups, shooters, and more!
http://www.chronocrash.com
BSD 3-Clause "New" or "Revised" License
894 stars 119 forks source link

Support windowing system DPI scaling in OpenGL video backend #312

Closed Plombo closed 3 months ago

Plombo commented 3 months ago

This produces better results than the windowing system's scaling on top of our own, since we can do high-quality scaling in the OpenGL backend.

Works with Windows and Wayland, and should work for Mac as well.

dbaldan commented 3 months ago

@Plombo I have a question about this. Will this high-quality scaling be optional or it will always works like that? Plus, OpenGL will be the defaut backend?

Because this raised many concerns to me.

Plombo commented 3 months ago

OpenGL has been the default backend for a long time, and its high-quality scaling support has been there for just as long. This just makes it so that Windows doesn't do its own upscaling on top of ours.

dbaldan commented 3 months ago

I see. Will the neareast neighbor scale still be available?

SumolX commented 3 months ago

I can confirm these changes are compatible with MacOS.

Plombo commented 3 months ago

The way it's worked for a while (not changed by this pull request) is that high quality is the only option for OpenGL, while the SDL backend has the old nearest-neighbor and linear filters. Also, to clear up any confusion, this is what the high-quality scaling actually produces:

So pixels stay sharp (not blurred like with linear filtering), but there is no issue with uneven scaling at non-integer factors (like with nearest-neighbor filtering).

dbaldan commented 3 months ago

Oh, great! for a second I was worried about it

Plombo commented 3 months ago

One problem is that contrary to what I thought initially, high-DPI support on Windows has to be turned on or off before SDL_Init, so we can't disable it for the SDL (non-OpenGL) video backend there. This will make the SDL backend look janky in windowed mode, but at least it's non-default and there's no real benefit to using it these days.

The above issue is Windows-only; we can still be toggle high-DPI support per-backend everywhere else (Linux/Wayland and Mac), so the SDL backend will still look okay there.

And even on Windows, this change is still an overall improvement. Having a default backend with properly sharp pixels and a non-default janky backend is an improvement over the status quo of two blurry ones.

dbaldan commented 3 months ago

"This will make the SDL backend look janky in windowed mode, but at least it's non-default and there's no real benefit to using it these days." this is exaclty what I use :(

Plombo commented 3 months ago

Why do you use it over the OpenGL backend? Does it provide some benefit?

Regardless of high-DPI support, the SDL backend has always been janky in fullscreen mode for similar reasons (uneven scaling factor).