highdpi support test

This commit is contained in:
RandomityGuy 2022-12-20 21:55:58 +05:30
parent 609c5dc1b7
commit 82ca9cde8e
9 changed files with 15 additions and 12 deletions

View file

@ -1,5 +1,6 @@
-cp src
-lib heaps
-lib hlsdl
-D highDPI
-hl native/marblegame.c
--main Main

View file

@ -6,5 +6,6 @@
--js marblegame.js
-D windowSize=1280x720
-D js-es=6
-D highDPI
--dce full
--main Main

View file

@ -6,5 +6,6 @@
-D windowSize=1280x720
-D js-es=6
-D keep-inline-positions
-D highDPI
--main Main
-debug

View file

@ -1,6 +1,7 @@
-cp src
-lib heaps
-lib hlsdl
-D highDPI
-hl native/marblegame.c
-D MACOS_BUNDLE
--main Main

View file

@ -4,5 +4,6 @@
-hl marblegame.hl
-D windowSize=1280x720
-D keep-inline-positions
-D highDPI
--main Main
-debug

View file

@ -115,7 +115,7 @@ class CameraController extends Object {
_ignoreCursor = false;
return;
}
var scaleFactor = 1.0;
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
#if js
scaleFactor = 1 / js.Browser.window.devicePixelRatio;
#end

View file

@ -22,11 +22,11 @@ import src.Settings;
class ResourceLoader {
#if (hl && !android)
#if MACOS_BUNDLE
#if MACOS_BUNDLE
public static var fileSystem:FileSystem = new TorqueFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "..", ".."])), null);
#else
#else
public static var fileSystem:FileSystem = new TorqueFileSystem(".", null);
#end
#end
#end
#if (js || android)
public static var fileSystem:FileSystem = null;
@ -316,8 +316,7 @@ class ResourceLoader {
texObj.flags.set(MipMapped);
}
var tex = img.toTexture();
tex.mipMap = Linear;
tex.filter = Linear;
tex.mipMap = Nearest;
// tex.filter = Nearest;
var textureresource = new Resource(tex, path, textureCache, tex -> tex.dispose());
textureCache.set(path, textureresource);

View file

@ -157,13 +157,12 @@ class Settings {
public static var isTouch:Option<Bool> = Option.None;
#if hl
#if MACOS_BUNDLE
#if MACOS_BUNDLE
public static var settingsDir = Path.join([Sys.getEnv("HOME"), "Library", "Application Support", "MBHaxe-MBP"]);
#else
#else
public static var settingsDir = ".";
#end
#end
#end
public static function applySettings() {
#if hl
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
@ -354,7 +353,7 @@ class Settings {
// @:privateAccess Window.getInstance().window.center();
Window.getInstance().addResizeEvent(() -> {
var wnd = Window.getInstance();
var zoomRatio = 1.0;
var zoomRatio = Window.getInstance().windowToPixelRatio;
#if js
var zoomRatio = Util.isTouchDevice() ? js.Browser.window.screen.height * js.Browser.window.devicePixelRatio / 600 : js.Browser.window.devicePixelRatio; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768;
Settings.zoomRatio = zoomRatio;

View file

@ -131,7 +131,7 @@ class GuiControl {
rect.position = parentRect.position.add(this.position.multiply(uiScaleFactor));
}
var scaleFactor = 1.0;
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
#if (js || android)
scaleFactor = 1 / Settings.zoomRatio; // 768 / js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio; // 0.5; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768;
#end