Fractional Scaling

This commit is contained in:
Snoweuph 2024-08-28 21:41:07 +02:00
parent 2b274fb8c8
commit e7336cbf82
Signed by: Snoweuph
GPG key ID: 0021ADF278B2F49B

View file

@ -19,19 +19,24 @@ public class GLWindow extends Window {
});
if (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND) {
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
assert vidmode != null;
GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
assert videoMode != null;
glfwSetWindowPos(
id,
(vidmode.width() - width) / 2,
(vidmode.height() - height) / 2
(videoMode.width() - width) / 2,
(videoMode.height() - height) / 2
);
}
addResizeCallback((int newWidth, int newHeight) -> {
GLWindow.this.width = newWidth;
GLWindow.this.height = newHeight;
glViewport(0, 0, newWidth, newHeight);
float[] x = new float[1];
float[] y = new float[1];
glfwGetWindowContentScale(getId(), x, y);
glViewport(0, 0, (int) (newWidth * x[0]), (int) (newHeight * y[0]));
});
GL.createCapabilities();