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

BaseTkOpenGlControl is not taking the correct ScaleFactor on MacOS #5

Open
DigitalBox98 opened this issue Mar 13, 2024 · 1 comment

Comments

@DigitalBox98
Copy link

The GL.Viewport() in the BaseTkOpenGlControl class should take into account the scale factor of the monitor in order to display correctly on MacOS.

In the below example, the viewport should be scaled by a factor of 2 to work fine :

screen

With OpenTK+ImGUI the below code is used when a window is resized for instance (OpenTK propose a GameWindow.FramebufferSize in order to have the correct value versus the Client size :

        // Update the opengl viewport
        Vector2i fb = this.FramebufferSize;
        GL.Viewport(0, 0, fb.X, fb.Y); // 2048 * 1536 

        // Tell ImGui of the new size
        _controller.WindowResized(ClientSize.X, ClientSize.Y); // 1024 * 768 

I don't know what is the equivalent for OpenTK+Avalonia, that's why I'm opening this issue

@DigitalBox98
Copy link
Author

Solution is to not use Bounds.Size and instead use the PixelSize as per Avalonia's answer on their repo :

private PixelSize GetPixelSize()
{
var scaling = TopLevel.GetTopLevel(this).RenderScaling;
return new PixelSize(Math.Max(1, (int)(Bounds.Width * scaling)),
Math.Max(1, (int)(Bounds.Height * scaling)));
}

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

No branches or pull requests

1 participant