Compare commits

..

2 commits

Author SHA1 Message Date
e7336cbf82
Fractional Scaling 2024-08-28 21:41:07 +02:00
2b274fb8c8
Refactoring 2024-08-28 21:39:49 +02:00
3 changed files with 11 additions and 6 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.idea/

View file

@ -2,7 +2,6 @@ package dev.euph.engine.opengl;
import dev.euph.engine.core.data.ImageLoader;
import dev.euph.engine.rendering.resources.Texture;
import dev.euph.engine.rendering.resources.loader.TextureLoader;
import java.net.URL;

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();