Skip to content

DPI fix (part 2)#267

Merged
michaelsakharov merged 3 commits intoProwlEngine:New-Editorfrom
PaperPrototype:fix-content-scale-windows-and-dpi-for-macos
Apr 27, 2026
Merged

DPI fix (part 2)#267
michaelsakharov merged 3 commits intoProwlEngine:New-Editorfrom
PaperPrototype:fix-content-scale-windows-and-dpi-for-macos

Conversation

@PaperPrototype
Copy link
Copy Markdown
Contributor

Still works on windows just need to test on macos

The root cause was that PreparePaperFrame was dividing Paper's resolution by ContentScale — on a 1x monitor cs=1 so this was a no-op and everything worked, but on Retina cs=2 so Paper's logical space was halved while the projection still covered the full 3024px framebuffer, leaving the UI crammed into the top-left quarter at half size.
…indowContentScale

glfwGetWindowContentScale returns the system DPI factor (e.g. 1.5) even
when the process is DPI-unaware, where the OS virtualises the framebuffer
so fbSize == winSize. The new PreparePaperFrame (resolution = winSize,
scale = cs) then produced vertices spanning winSize × 1.5 > fbSize,
pushing the UI off-screen on any Windows machine with DPI > 100%.

The fb/win ratio is always the correct value: it measures actual pixel
density from the app's coordinate perspective regardless of platform or
DPI-awareness mode. On macOS the GLFW proc already failed and fell back
to this ratio; now Windows uses the same path.
…ime and this is the fix. Now I just need to test on mac

On DPI-unaware Windows, winSize == fbSize but glfwGetWindowContentScale still returns the real system DPI (1.25, 1.5, etc.). The PR's formula used winSize as Paper's resolution, so vertex_max = winSize × cs > fbSize. The pre-PR formula happened to work because it divided winSize by cs first and then multiplied back via scale = cs, which collapsed to winSize = fbSize.

Fix: Always derive resolution from fbSize / (cs × us) so vertex_max = fbSize regardless. Mouse and cursor also get a separate csFbWin = fbSize/winSize factor — on macOS csFbWin == cs so it cancels out (no behavior change), but on DPI-unaware Windows csFbWin = 1 while cs = 1.25, so the division by cs correctly maps the mouse into the compressed paper space.
@PaperPrototype
Copy link
Copy Markdown
Contributor Author

Only does "TryGetContentScaleViaProc" for windows

@PaperPrototype
Copy link
Copy Markdown
Contributor Author

Okay confirmed it still works on macos

@michaelsakharov michaelsakharov merged commit aa9f39a into ProwlEngine:New-Editor Apr 27, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants