HiDPI scaling
It would be good if it possible to have a fractional scaling for texts/dialogs, menus and health/mana indicators on HiDPI screens.
Short overview on existing solutions:
- Android way
Have pixel-based api, but expose scale factor. Works, but trashes code with
*dpiconversions. - Windows way Hide all under the hood. All api that are claim to use pixels do scale-multiplication internally. Convenient, but doesn't fit 3D content.
Option 1
Quite bad for coding, since dpi scale will pollute all 2d code, and practically untestable - better not to use.
Option 2
Has issues as well:
Swaphain should match physical size of parent window, otherwise scaling is not defined. So scaling on MainWindow is a problem.
It's not exactly clear where scaling should be put in.
Maybe for starters we could just change the resolution? We don't really need to run gothic at 4k
For MacOS I just used scale factor, but it is rather dirty hack until we can change resolution.
/lib/Tempest/Engine/system/api/macosapi.mm
void Detail::ImplMacOSApi::onDidResize(void* hwnd, void* w) {
auto cb = reinterpret_cast<Tempest::Window*>(hwnd);
NSWindow* wnd = reinterpret_cast<NSWindow*>(w);
NSRect fr = windowRect(wnd);
fr = [wnd convertRectToBacking:fr];
double scaleFactor = [wnd backingScaleFactor];
SizeEvent sz{int32_t(fr.size.width/scaleFactor),int32_t(fr.size.height/scaleFactor)};
MacOSApi::dispatchResize(*cb,sz);
}
Is there any way to scale dialogs for a starter? Any settings for that?
Is there any way to scale dialogs for a starter? Any settings for that?
We are missing INTERFACE/scale flag from systempack at this moment - need to implement.
for reference:
[INTERFACE]
Scale=0
; ... Automatic interface scaling, resolution 1024x768 used as base for autoscale algorithm.
; on (1) or (1.1 ... and higher), - Interface scaling in n-times on the discretion of the user.
; maximum value depend on vertical resolution.
; for exapmle, for 1920x1080 it will be 1080/512 = 2.10.
; for 3840x2160 it will be 2160/512 = 4.21.
; higher values will be readed as maximum value.
; off (0), - without scaling. Default is 1.
Except auto-scaling here is questionable - dpi based sceling, seems to be way better option.
@Try maybe I can set resolution to 1360×768 or something? I really don't need a high res gothic 2. When I try to change resolution in settings, it changes something, but making the game kinda blurry, not squary.
When I try to change resolution in settings, it changes something, but making the game kinda blurry, not squary.
it changes only rendering resolution for 3D and upscales it a bit during tonemapping phase.
Just my 2 cents here. If you choose 1024x768 as base, why don't you just let it auto scale from that with DPI in mind? https://www.reddit.com/r/vulkan/comments/8jlgt2/surface_capabilities_and_dpi_scaling/ so it would be possible to get a DPI value to include in your calculation. For crazy ppl you could even add Scale=2 for manual factor setting and another value for your favorite factor. Everyone would be happy by that. Maybe I am not gaming enough anymore, but I barely ever heard of a game that decided to follow the DPI factor Windows is set to.
@lectricas as a temporary workaround I can suggest switching your whole system to a lower res before starting the game; OpenGothic will reuse the current system resolution.
@Nindaleth I've downlaoded EasyRes from app store to change resolution and set 1280x800 and run the game. Then I got the white screen. Turning resolution back to default reversed the problem. Have you done this procedure? Any steps how to make it work 100%?
App Store? Is it not possible on macOS to change the system resolution from an official system dialog? Sorry, I only have experience with Windows and Linux OSs where this is built-in and just works (no sarcasm intended).
Of course it's possible. Apple just loves to hide the actual numbers (you can see them on mouseover).
Ok, guys, I gave it another try and put @wiktorskowronski fix and it works, although all the items are messed up:
UPD: So, for those who just want to play the game, modify this method:
void InventoryRenderer::drawItem(int x, int y, int w, int h, const ::Item& item) {
x = x*2;
y = y*2;
w = w*2;
h = h*2;
...
}
together with a fix from @wiktorskowronski
What we've done here is increased the position and size of the items by 2, because with @wiktorskowronski fix we scaled down everything.
backingScaleFactor is 2 by default.
https://developer.apple.com/documentation/appkit/nswindow/1419459-backingscalefactor