Fractional Scaling
This commit is contained in:
parent
2b274fb8c8
commit
e7336cbf82
1 changed files with 10 additions and 5 deletions
|
@ -19,19 +19,24 @@ public class GLWindow extends Window {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND) {
|
if (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND) {
|
||||||
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
||||||
assert vidmode != null;
|
assert videoMode != null;
|
||||||
glfwSetWindowPos(
|
glfwSetWindowPos(
|
||||||
id,
|
id,
|
||||||
(vidmode.width() - width) / 2,
|
(videoMode.width() - width) / 2,
|
||||||
(vidmode.height() - height) / 2
|
(videoMode.height() - height) / 2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
addResizeCallback((int newWidth, int newHeight) -> {
|
addResizeCallback((int newWidth, int newHeight) -> {
|
||||||
GLWindow.this.width = newWidth;
|
GLWindow.this.width = newWidth;
|
||||||
GLWindow.this.height = newHeight;
|
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();
|
GL.createCapabilities();
|
||||||
|
|
Loading…
Reference in a new issue