Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research: macOS MTKView wobbly resizing... #700

Closed
floooh opened this issue Aug 6, 2022 · 1 comment
Closed

Research: macOS MTKView wobbly resizing... #700

floooh opened this issue Aug 6, 2022 · 1 comment

Comments

@floooh
Copy link
Owner

floooh commented Aug 6, 2022

Resizing with MTKView results in a 'wobbly' window content because the backing store doesn't exactly the current window size, and MTKView scaling the content.

See: https://thume.ca/2019/06/19/glitchless-metal-window-resizing/

What appears to work great for high-dpi apps is to set the MTKView's layerContentsPlacement policy to topleft, and enable autoResizeDrawable:

_sapp.macos.view.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft;
_sapp.macos.view.autoResizeDrawable = true;

...and then not manually setting the view's drawable size (however whether that's done or not doesn't seem to make a difference).

This gives a wonderfully stable window content when resizing. Unfortunately it breaks under some circumstances:

  • non-highdpi apps only render into the top-left quarter
  • moving a highdpi window from a Retina screen to a non-Retina screen has the same effect (only rendering into the top-left quarter)

...this needs more investigation, also consider dropping MTKView completely.

@floooh
Copy link
Owner Author

floooh commented Jan 8, 2024

Fixed in #963, many thanks to @Seb-degraff for picking up this long standing issue :)

@floooh floooh closed this as completed Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant