diff --git a/JavaApp/src/main/java/HelloWorld.java b/JavaApp/src/main/java/HelloWorld.java index bfcfd4c9..5fb508c2 100644 --- a/JavaApp/src/main/java/HelloWorld.java +++ b/JavaApp/src/main/java/HelloWorld.java @@ -73,8 +73,14 @@ public class HelloWorld { // Get the resolution of the primary monitor GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); - - System.out.println("Actual width=" + vidmode.width() + ", height=" + vidmode.height()); + + System.out.println("MONITOR SPEC"); + System.out.println("width=" + vidmode.width()); + System.out.println("height=" + vidmode.height()); + System.out.println("red=" + vidmode.redBits()); + System.out.println("green=" + vidmode.greenBits()); + System.out.println("blue=" + vidmode.blueBits()); + System.out.println("refresh=" + vidmode.refreshRate()); // Center the window glfwSetWindowPos( @@ -135,4 +141,4 @@ public class HelloWorld { new HelloWorld().run(); } -} \ No newline at end of file +} diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java index 6b057082..5d89b2a7 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/uikit/UIKit.java @@ -16,8 +16,7 @@ public class UIKit { } public static void callback_SurfaceViewController_launchMinecraft(int width, int height) { - GLFW.mGLFWWindowWidth = width; - GLFW.mGLFWWindowHeight = height; + GLFW.internalChangeMonitorSize(width, height); CallbackBridge.mouseX = width / 2; CallbackBridge.mouseY = height / 2; PLaunchApp.launchMinecraft(); diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java b/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java index fabde15e..4c9cd70c 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java @@ -517,19 +517,11 @@ public class GLFW mGLFWVideoMode = new GLFWVidMode(ByteBuffer.allocateDirect(GLFWVidMode.SIZEOF)); /* - memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.WIDTH, mGLFWWindowWidth); - memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.HEIGHT, mGLFWWindowHeight); - memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REDBITS, 8); - memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.GREENBITS, 8); - memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.BLUEBITS, 8); - memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REFRESHRATE, 60); + memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.REDBITS, 8); + memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.GREENBITS, 8); + memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.BLUEBITS, 8); + memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.REFRESHRATE, 60); */ - - GLFWVidMode.WIDTH = mGLFWWindowWidth; - GLFWVidMode.HEIGHT = mGLFWWindowHeight; - GLFWVidMode.REDBITS = GLFWVidMode.GREENBITS = GLFWVidMode.BLUEBITS = 8; - GLFWVidMode.REFRESHRATE = 60; - // A way to generate key code names Field[] thisFieldArr = GLFW.class.getFields(); try { @@ -618,6 +610,13 @@ public class GLFW return GLFW; } + public static void internalChangeMonitorSize(int width, int height) { + mGLFWWindowWidth = width; + mGLFWWindowHeight = height; + memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.WIDTH, mGLFWWindowWidth); + memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.HEIGHT, mGLFWWindowHeight); + } + public static GLFWWindowProperties internalGetWindow(long window) { GLFWWindowProperties win = mGLFWWindowMap.get(window); if (win == null) { @@ -1111,8 +1110,7 @@ public class GLFW break; case CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE: case CallbackBridge.EVENT_TYPE_WINDOW_SIZE: - mGLFWWindowWidth = dataArr[1]; - mGLFWWindowHeight = dataArr[2]; + internalChangeMonitorSize(dataArr[1], dataArr[2]); glfwSetWindowSize(ptr, mGLFWWindowWidth, mGLFWWindowHeight); if (dataArr[0] == CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE && mGLFWFramebufferSizeCallback != null) { mGLFWFramebufferSizeCallback.invoke(ptr, mGLFWWindowWidth, mGLFWWindowHeight); diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java index 9ed61258..a86e1b4a 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java @@ -49,13 +49,13 @@ public class GLFWVidMode extends Struct { public static final int ALIGNOF; /** The struct member offsets. */ - public static /* final */ int - WIDTH, - HEIGHT, - REDBITS, - GREENBITS, - BLUEBITS, - REFRESHRATE; + public static final int + WIDTH, + HEIGHT, + REDBITS, + GREENBITS, + BLUEBITS, + REFRESHRATE; static { Layout layout = __struct( @@ -69,6 +69,13 @@ public class GLFWVidMode extends Struct { SIZEOF = layout.getSize(); ALIGNOF = layout.getAlignment(); + + WIDTH = layout.offsetof(0); + HEIGHT = layout.offsetof(1); + REDBITS = layout.offsetof(2); + GREENBITS = layout.offsetof(3); + BLUEBITS = layout.offsetof(4); + REFRESHRATE = layout.offsetof(5); } /** @@ -129,17 +136,17 @@ public class GLFWVidMode extends Struct { // ----------------------------------- /** Unsafe version of {@link #width}. */ - public static int nwidth(long struct) { return WIDTH; } + public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.WIDTH); } /** Unsafe version of {@link #height}. */ - public static int nheight(long struct) { return HEIGHT; } + public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); } /** Unsafe version of {@link #redBits}. */ - public static int nredBits(long struct) { return REDBITS; } + public static int nredBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); } /** Unsafe version of {@link #greenBits}. */ - public static int ngreenBits(long struct) { return GREENBITS; } + public static int ngreenBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); } /** Unsafe version of {@link #blueBits}. */ - public static int nblueBits(long struct) { return BLUEBITS; } + public static int nblueBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); } /** Unsafe version of {@link #refreshRate}. */ - public static int nrefreshRate(long struct) { return REFRESHRATE; } + public static int nrefreshRate(long struct) { return 60; } // UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); } // ----------------------------------- @@ -194,4 +201,4 @@ public class GLFWVidMode extends Struct { } -} \ No newline at end of file +} diff --git a/JavaApp/src/main/java/org/lwjgl/opengl/Display.java b/JavaApp/src/main/java/org/lwjgl/opengl/Display.java index 780df3dc..91f2a99c 100644 --- a/JavaApp/src/main/java/org/lwjgl/opengl/Display.java +++ b/JavaApp/src/main/java/org/lwjgl/opengl/Display.java @@ -72,16 +72,11 @@ public class Display { static { Sys.initialize(); // init using dummy sys method - GLFWVidMode.WIDTH = GLFW.mGLFWWindowWidth; - GLFWVidMode.HEIGHT = GLFW.mGLFWWindowHeight; - long monitor = glfwGetPrimaryMonitor(); GLFWVidMode vidmode = glfwGetVideoMode(monitor); - int monitorWidth = displayWidth = displayFramebufferWidth = GLFW.mGLFWWindowWidth; - // vidmode.width(); - int monitorHeight = displayHeight = displayFramebufferHeight = GLFW.mGLFWWindowHeight; - // vidmode.height(); + int monitorWidth = displayWidth = displayFramebufferWidth = vidmode.width(); + int monitorHeight = displayHeight = displayFramebufferHeight = vidmode.height(); int monitorBitPerPixel = vidmode.redBits() + vidmode.greenBits() + vidmode.blueBits(); int monitorRefreshRate = vidmode.refreshRate();