Skip to content

Commit b513147

Browse files
committed
further cleanup of documentation about windows scaling
1 parent b1803cb commit b513147

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

build/windows/fenster/README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ Generally speaking, this is a nightmare to deal with. The solution, starting in
1010
With those values in hand, the sketch sets the `sun.java2d.uiScale` to either 1 or 2. Using fractional values produces [ugly results](https://github.com/processing/processing4/issues/378). Similarly, we do not set uiScale to 3 when scaling is at 300%. If you want larger sketches, use `scale()` in your code.
1111

1212

13-
# Approaches
14-
1513
## Using AWT
1614

17-
The [Toolkit.getScreenResolution()](https://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html#getScreenResolution--) method does what we want, but as soon as any AWT calls are made, it's no longer possible to set the property for `sun.java2d.uiScale` once AWT calls have been made.
15+
The [`Toolkit.getScreenResolution()`](https://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html#getScreenResolution--) method does what we want, but it's not possible to set the property for sun.java2d.uiScale once AWT calls have been made.
1816

1917

2018
## Use a helper application
@@ -26,13 +24,15 @@ This was done by first doing the JNI setup with MSYS2, and then adding a line to
2624

2725
## Use JNI
2826

29-
* A long explanation of a lot of this that might be helpful for someone, though didn't use it
30-
* <https://mariusbancila.ro/blog/2021/05/19/how-to-build-high-dpi-aware-native-desktop-applications/>
27+
This was the intended approach, however the result works 3 times in 5, has an immediate `segmentation fault` another 20% of the time, and the rest of the time just hangs completely until a force quit. If anyone can fix it, [let us know](https://github.com/processing/processing4/issues).
28+
29+
* Used this really helpful tutorial for JNI
30+
* <https://www.baeldung.com/jni>
3131

3232

3333
### Building the JNI code
3434

35-
* Install MSYS2 from <https://www.msys2.org/>.
35+
* Install MSYS2 from <https://www.msys2.org/> via <https://www.mingw-w64.org/downloads/#msys2>
3636

3737
* Within an MSYS shell, run updates and install `gcc`
3838

@@ -47,6 +47,16 @@ This was done by first doing the JNI setup with MSYS2, and then adding a line to
4747
* <https://stackoverflow.com/a/51775636>
4848
* other approaches for it <https://gist.github.com/ssfang/e52c00cd446081cd72a982a2dd8634d4#file-readme-md> (section under “jni with cygwin gcc”)
4949

50+
* To cross compile on macOS, use:
51+
52+
brew install mingw-w64
53+
54+
This installs `g++` as `x86_64-w64-mingw32-g++`.
55+
56+
Did not use this approach because it would require Windows testing anyway, so it has limited utility.
57+
58+
A link to the formula: <https://formulae.brew.sh/formula/mingw-w64>
59+
5060

5161
### Windows Reference
5262

@@ -59,6 +69,14 @@ Resources for the necessary API calls on Windows
5969
* Browse code samples for “dpi”
6070
* <https://docs.microsoft.com/en-us/samples/browse/?redirectedfrom=TechNet-Gallery&terms=dpi>
6171

72+
The code boils down to:
73+
74+
```c
75+
hdc = GetDC(NULL);
76+
horizontalDPI = GetDeviceCaps(hdc, LOGPIXELSX);
77+
verticalDPI = GetDeviceCaps(hdc, LOGPIXELSY);
78+
```
79+
6280

6381
## Use JNA
6482

@@ -121,3 +139,9 @@ It's also possible that calling `reg query` would kick off User Access Control h
121139

122140
* DPI-related APIs and registry settings
123141
* <https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dpi-related-apis-and-registry-settings?view=windows-11>
142+
143+
144+
## Other Resources
145+
146+
* A longer explanation of some of the issues in play that might be helpful for someone, though I didn't use it:
147+
* <https://mariusbancila.ro/blog/2021/05/19/how-to-build-high-dpi-aware-native-desktop-applications/>

0 commit comments

Comments
 (0)