From 91a49ecb3f831ab1a91cc040bc013ad5da5dc5c4 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 21 Nov 2021 23:33:56 -0600 Subject: [PATCH 01/22] =?UTF-8?q?This=20is=20a=20very=20simple=20addition.?= =?UTF-8?q?=20It=20allows=20a=20person=20to=20set=203=20variables=20in=20A?= =?UTF-8?q?ppSettings.=20=E2=80=98CenterWindow=E2=80=99,=20=E2=80=98Window?= =?UTF-8?q?XPosition=E2=80=99=20and=20=E2=80=98WindowYPosition=E2=80=99=20?= =?UTF-8?q?variables.=20This=20way=20these=20variable=20will=20be=20saved?= =?UTF-8?q?=20in=20the=20profile=20when=20the=20profile=20is=20saved,=20an?= =?UTF-8?q?d=20be=20reloaded.=20I=20added=20=E2=80=98CenterWindow=E2=80=99?= =?UTF-8?q?=20to=20be=20added=20with=20a=20=E2=80=98true=E2=80=99=20value?= =?UTF-8?q?=20for=20the=20default=20value=20so=20it=20will=20run=20just=20?= =?UTF-8?q?like=20it=20did=20before.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit But if you set ‘CenterWindow’ to ‘false’ then inside LwjglWindow.java (lwjgl3 code) it will look at these new values, it will determine to center the window or use the position values to place the window back at the location the user last moved it to. Of course, these values are only updated if the “program” updates this value. So if you want to save screen position, you can save them on closing to and on restart put the window back into the same location. --- .../java/com/jme3/system/AppSettings.java | 62 +++++++++++++++++++ .../com/jme3/system/lwjgl/LwjglWindow.java | 9 ++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 7617b1d38b..9c89260a33 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -266,6 +266,7 @@ public final class AppSettings extends HashMap { public static final String JOAL = "JOAL"; static { + defaults.put("CenterWindow", true); defaults.put("Width", 640); defaults.put("Height", 480); defaults.put("BitsPerPixel", 24); @@ -1350,4 +1351,65 @@ public boolean isUseRetinaFrameBuffer() { public void setUseRetinaFrameBuffer(boolean useRetinaFrameBuffer) { putBoolean("UseRetinaFrameBuffer", useRetinaFrameBuffer); } + + /** + * Get the Center Window state + * + * @return true for center the window in the middle of the screen + * @see #setCenterWindow(boolean) + */ + public boolean getCenterWindow() { + return getBoolean("CenterWindow"); + } + + /** + * True to enable center the window. + * + * @param center whether to center the window or not. + */ + public void setCenterWindow(boolean center) { + putBoolean("CenterWindow", center); + } + + + /** + * Get the position of the window's X Position + * + * @return int screen coordinates of the X Position of the window + * @see #setWindowXPosition(int) + */ + public int getWindowXPosition() { + return getInteger("windowXpos"); + } + + /** + * The position of the window's X Position. + * + * @param pos screen coordinates for the X position. + */ + public void setWindowXPosition(int pos) { + putInteger("windowXpos", pos); + } + + + /** + * Get the position of the window's Y Position + * + * @return int screen coordinates of the Y Position of the window + * @see #setWindowXPosition(int) + */ + public int getWindowYPosition() { + return getInteger("windowYpos"); + } + + /** + * The position of the window's Y Position. + * + * @param pos screen coordinates for the Y position. + */ + public void setWindowYPosition(int pos) { + putInteger("windowYpos", pos); + } + + } diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index abf13eb1c5..19be449111 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -276,11 +276,16 @@ public void invoke(final long window, final boolean focus) { } }); - // Center the window if (!settings.isFullscreen()) { - glfwSetWindowPos(window, + if (settings.getCenterWindow()) + { + // Center the window + glfwSetWindowPos(window, (videoMode.width() - settings.getWidth()) / 2, (videoMode.height() - settings.getHeight()) / 2); + } else { + glfwSetWindowPos(window,settings.getWindowXPosition(), settings.getWindowYPosition()); + } } // Make the OpenGL context current From ce2471656fe8d3874ab5a1d4f1f87753839508cb Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 23 Nov 2021 23:43:34 -0600 Subject: [PATCH 02/22] formatting and comments changes. --- .../java/com/jme3/system/AppSettings.java | 26 +++++++++++++------ .../com/jme3/system/lwjgl/LwjglWindow.java | 3 +-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 9c89260a33..4ecf733682 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -291,6 +291,8 @@ public final class AppSettings extends HashMap { defaults.put("OpenCL", false); defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName()); defaults.put("UseRetinaFrameBuffer", true);// MacOS spec + defaults.put("windowYpos", 0); + defaults.put("windowXpos", 0); // defaults.put("Icons", null); } @@ -1353,9 +1355,9 @@ public void setUseRetinaFrameBuffer(boolean useRetinaFrameBuffer) { } /** - * Get the Center Window state + * Get the Centering Window state * - * @return true for center the window in the middle of the screen + * @return true to center the window in the middle of the screen * @see #setCenterWindow(boolean) */ public boolean getCenterWindow() { @@ -1363,7 +1365,7 @@ public boolean getCenterWindow() { } /** - * True to enable center the window. + * True to enable centering the window. * * @param center whether to center the window or not. */ @@ -1373,7 +1375,9 @@ public void setCenterWindow(boolean center) { /** - * Get the position of the window's X Position + * Get the window's X Position on the screen. + * This value is ignored when CenterWindow is set to true + * @see #setCenterWindow(boolean) * * @return int screen coordinates of the X Position of the window * @see #setWindowXPosition(int) @@ -1383,7 +1387,9 @@ public int getWindowXPosition() { } /** - * The position of the window's X Position. + * Set the window's X Position on the screen. + * This value is ignored when CenterWindow is set to true + * @see #setCenterWindow(boolean) * * @param pos screen coordinates for the X position. */ @@ -1393,7 +1399,9 @@ public void setWindowXPosition(int pos) { /** - * Get the position of the window's Y Position + * Get the window's Y Position on the screen. + * This value is ignored when CenterWindow is set to true + * @see #setCenterWindow(boolean) * * @return int screen coordinates of the Y Position of the window * @see #setWindowXPosition(int) @@ -1403,9 +1411,11 @@ public int getWindowYPosition() { } /** - * The position of the window's Y Position. + * Set the window's Y Position on the screen. + * This value is ignored when CenterWindow is set to true + * @see #setCenterWindow(boolean) * - * @param pos screen coordinates for the Y position. + * @param pos screen coordinates for the Y position of the window. */ public void setWindowYPosition(int pos) { putInteger("windowYpos", pos); diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index 19be449111..36345b8883 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -277,8 +277,7 @@ public void invoke(final long window, final boolean focus) { }); if (!settings.isFullscreen()) { - if (settings.getCenterWindow()) - { + if (settings.getCenterWindow()) { // Center the window glfwSetWindowPos(window, (videoMode.width() - settings.getWidth()) / 2, From aef358f1e13a81b9092cbcc8f109876aaa303a15 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Nov 2021 12:52:37 -0600 Subject: [PATCH 03/22] jme3test.app.TestApplication hangs with LWJGL3 #1193 LWJGL3-JME library would block the current thread when executing LWJGL3. Instead of calling run() that is blocking, made it work like LWJGL2-JME library when they start it as a thread so run gets called. I commented out the run() function and replaced it with Thread.start(). --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index 36345b8883..83c919df76 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -478,7 +478,8 @@ public void create(boolean waitFor) { // NOTE: this is required for Mac OS X! mainThread = Thread.currentThread(); mainThread.setName("jME3 Main"); - run(); + new Thread(this, "jME3 Main").start(); +// run(); } /** From f0489b89dffb71338db3d6d084b800a330f81817 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Nov 2021 19:47:31 -0600 Subject: [PATCH 04/22] removing unwanted changes, since you can't do multiple pull requests at once. --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index 83c919df76..a6b3636dd3 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -280,8 +280,8 @@ public void invoke(final long window, final boolean focus) { if (settings.getCenterWindow()) { // Center the window glfwSetWindowPos(window, - (videoMode.width() - settings.getWidth()) / 2, - (videoMode.height() - settings.getHeight()) / 2); + (videoMode.width() - settings.getWidth()) / 2, + (videoMode.height() - settings.getHeight()) / 2); } else { glfwSetWindowPos(window,settings.getWindowXPosition(), settings.getWindowYPosition()); } @@ -478,8 +478,7 @@ public void create(boolean waitFor) { // NOTE: this is required for Mac OS X! mainThread = Thread.currentThread(); mainThread.setName("jME3 Main"); - new Thread(this, "jME3 Main").start(); -// run(); + run(); } /** From a5b0e37ce5f5242d54026247492703dbae776b6a Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Nov 2021 19:50:32 -0600 Subject: [PATCH 05/22] formatting issues. --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index a6b3636dd3..e3030e0471 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -283,7 +283,8 @@ public void invoke(final long window, final boolean focus) { (videoMode.width() - settings.getWidth()) / 2, (videoMode.height() - settings.getHeight()) / 2); } else { - glfwSetWindowPos(window,settings.getWindowXPosition(), settings.getWindowYPosition()); + glfwSetWindowPos(window,settings.getWindowXPosition(), + settings.getWindowYPosition()); } } From 26937cac7d68cff1400e7e33c6f531637bf86200 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Nov 2021 19:53:02 -0600 Subject: [PATCH 06/22] changed parameter naming to be more consistency with other items. --- .../src/main/java/com/jme3/system/AppSettings.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 4ecf733682..dbc5ebdc93 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -291,8 +291,8 @@ public final class AppSettings extends HashMap { defaults.put("OpenCL", false); defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName()); defaults.put("UseRetinaFrameBuffer", true);// MacOS spec - defaults.put("windowYpos", 0); - defaults.put("windowXpos", 0); + defaults.put("windowYPosition", 0); + defaults.put("windowXPosition", 0); // defaults.put("Icons", null); } @@ -1383,7 +1383,7 @@ public void setCenterWindow(boolean center) { * @see #setWindowXPosition(int) */ public int getWindowXPosition() { - return getInteger("windowXpos"); + return getInteger("windowXPosition"); } /** @@ -1394,7 +1394,7 @@ public int getWindowXPosition() { * @param pos screen coordinates for the X position. */ public void setWindowXPosition(int pos) { - putInteger("windowXpos", pos); + putInteger("windowXPosition", pos); } @@ -1407,7 +1407,7 @@ public void setWindowXPosition(int pos) { * @see #setWindowXPosition(int) */ public int getWindowYPosition() { - return getInteger("windowYpos"); + return getInteger("windowYPosition"); } /** @@ -1418,7 +1418,7 @@ public int getWindowYPosition() { * @param pos screen coordinates for the Y position of the window. */ public void setWindowYPosition(int pos) { - putInteger("windowYpos", pos); + putInteger("windowYPosition", pos); } From 3832d372f43d0fd3569a37f62ecf334094bdeb82 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Nov 2021 20:15:40 -0600 Subject: [PATCH 07/22] jme3test.app.TestApplication hangs with LWJGL3 #1193 LWJGL3-JME projects was doing a call that is blocking the current thread. I changed it to match how LWJGL2-JME project launches the Context Window. --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index e3030e0471..a7ab37ec9e 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -479,7 +479,7 @@ public void create(boolean waitFor) { // NOTE: this is required for Mac OS X! mainThread = Thread.currentThread(); mainThread.setName("jME3 Main"); - run(); + new Thread(this, "jME3 Main").start(); } /** From 811493c4f2bc343e0ff589bfbde99079d7219a5c Mon Sep 17 00:00:00 2001 From: bob0bob <30982580+bob0bob@users.noreply.github.com> Date: Wed, 24 Nov 2021 20:42:39 -0600 Subject: [PATCH 08/22] jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3) LWJGL3-JME projects was doing a call that is blocking the current thread. I changed it to match how LWJGL2-JME project launches the Context Window. From db0d9ffb1beb45ec377947ef85874366f09f1024 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 24 Nov 2021 21:03:52 -0600 Subject: [PATCH 09/22] removing unwanted changes. --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index a7ab37ec9e..e3030e0471 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -479,7 +479,7 @@ public void create(boolean waitFor) { // NOTE: this is required for Mac OS X! mainThread = Thread.currentThread(); mainThread.setName("jME3 Main"); - new Thread(this, "jME3 Main").start(); + run(); } /** From 5eb269079ebb90705f4dfdc6faaf63502527e90d Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Tue, 30 Nov 2021 10:45:49 -0800 Subject: [PATCH 10/22] AppSettings: enhance the new javadoc --- .../java/com/jme3/system/AppSettings.java | 68 ++++++++++++------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index dbc5ebdc93..21c8373d46 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -1355,9 +1355,13 @@ public void setUseRetinaFrameBuffer(boolean useRetinaFrameBuffer) { } /** - * Get the Centering Window state + * Tests the state of the Center Window flag. * - * @return true to center the window in the middle of the screen + *

The Center Window flag is used only with LWJGL3 and has no effect on + * fullscreen windows. + * + * @return true to center the window on the desktop, false to position the + * window at (WindowXPosition, WindowYPosition) * @see #setCenterWindow(boolean) */ public boolean getCenterWindow() { @@ -1365,61 +1369,79 @@ public boolean getCenterWindow() { } /** - * True to enable centering the window. + * Enables or disables the Center Window flag. + * + *

The Center Window flag is used only with LWJGL3 and has no effect on + * fullscreen windows. It defaults to true. * - * @param center whether to center the window or not. + * @param center true to center the window on the desktop, false to position + * the window at (WindowXPosition, WindowYPosition) */ public void setCenterWindow(boolean center) { putBoolean("CenterWindow", center); } - /** - * Get the window's X Position on the screen. - * This value is ignored when CenterWindow is set to true + * Gets the window's initial X position on the desktop. + * + *

This setting is used only with LWJGL3, has no effect on fullscreen + * windows, and is ignored if the Center Window flag is true. + * * @see #setCenterWindow(boolean) * - * @return int screen coordinates of the X Position of the window + * @return the initial position of the window's left edge relative to the + * left edge of the desktop * @see #setWindowXPosition(int) */ public int getWindowXPosition() { return getInteger("windowXPosition"); } - + /** - * Set the window's X Position on the screen. - * This value is ignored when CenterWindow is set to true + * Sets the window's initial X position on the desktop. + * + *

This setting is used only with LWJGL3, has no effect on fullscreen + * windows, and is ignored if the Center Window flag is true. Its default + * value is 0. + * * @see #setCenterWindow(boolean) * - * @param pos screen coordinates for the X position. + * @param pos the desired initial position of the window's left edge + * relative to the left edge of the desktop */ public void setWindowXPosition(int pos) { putInteger("windowXPosition", pos); } - /** - * Get the window's Y Position on the screen. - * This value is ignored when CenterWindow is set to true + * Gets the window's initial Y position on the desktop. + * + *

This setting is used only with LWJGL3, has no effect on fullscreen + * windows, and is ignored if the Center Window flag is true. + * * @see #setCenterWindow(boolean) * - * @return int screen coordinates of the Y Position of the window - * @see #setWindowXPosition(int) + * @return the initial position of the window's upper edge relative to the + * upper edge of the desktop + * @see #setWindowYPosition(int) */ public int getWindowYPosition() { return getInteger("windowYPosition"); } - + /** - * Set the window's Y Position on the screen. - * This value is ignored when CenterWindow is set to true + * Sets the window's initial Y position on the desktop. + * + *

This setting is used only with LWJGL3, has no effect on fullscreen + * windows, and is ignored if the Center Window flag is true. Its default + * value is 0. + * * @see #setCenterWindow(boolean) * - * @param pos screen coordinates for the Y position of the window. + * @param pos the desired initial position of the window's upper edge + * relative to the upper edge of the desktop */ public void setWindowYPosition(int pos) { putInteger("windowYPosition", pos); } - - } From 72d008dbe40fb1e2d442bce821b0fa5e80162398 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Tue, 30 Nov 2021 10:54:25 -0800 Subject: [PATCH 11/22] AppSettings: capitalize Window{X/Y}Position consistent w/other settings --- .../src/main/java/com/jme3/system/AppSettings.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 21c8373d46..e45eb51945 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -291,8 +291,8 @@ public final class AppSettings extends HashMap { defaults.put("OpenCL", false); defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName()); defaults.put("UseRetinaFrameBuffer", true);// MacOS spec - defaults.put("windowYPosition", 0); - defaults.put("windowXPosition", 0); + defaults.put("WindowYPosition", 0); + defaults.put("WindowXPosition", 0); // defaults.put("Icons", null); } @@ -1394,7 +1394,7 @@ public void setCenterWindow(boolean center) { * @see #setWindowXPosition(int) */ public int getWindowXPosition() { - return getInteger("windowXPosition"); + return getInteger("WindowXPosition"); } /** @@ -1410,7 +1410,7 @@ public int getWindowXPosition() { * relative to the left edge of the desktop */ public void setWindowXPosition(int pos) { - putInteger("windowXPosition", pos); + putInteger("WindowXPosition", pos); } /** @@ -1426,7 +1426,7 @@ public void setWindowXPosition(int pos) { * @see #setWindowYPosition(int) */ public int getWindowYPosition() { - return getInteger("windowYPosition"); + return getInteger("WindowYPosition"); } /** @@ -1442,6 +1442,6 @@ public int getWindowYPosition() { * relative to the upper edge of the desktop */ public void setWindowYPosition(int pos) { - putInteger("windowYPosition", pos); + putInteger("WindowYPosition", pos); } } From f7c5ec7eeeb349e319c79bf817428654e3f7ee21 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Tue, 30 Nov 2021 11:36:00 -0800 Subject: [PATCH 12/22] LwjglWindow: convert tabs to spaces --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index e3030e0471..e47c9e3a69 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -280,11 +280,12 @@ public void invoke(final long window, final boolean focus) { if (settings.getCenterWindow()) { // Center the window glfwSetWindowPos(window, - (videoMode.width() - settings.getWidth()) / 2, - (videoMode.height() - settings.getHeight()) / 2); + (videoMode.width() - settings.getWidth()) / 2, + (videoMode.height() - settings.getHeight()) / 2); } else { - glfwSetWindowPos(window,settings.getWindowXPosition(), - settings.getWindowYPosition()); + glfwSetWindowPos(window, + settings.getWindowXPosition(), + settings.getWindowYPosition()); } } From 4544d6446ffa0d4499085fc822d7b6ec45d57322 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Tue, 30 Nov 2021 11:45:50 -0800 Subject: [PATCH 13/22] AppSettings: re-arrange @see tags in javadoc --- .../src/main/java/com/jme3/system/AppSettings.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index e45eb51945..4400baf376 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -1387,10 +1387,9 @@ public void setCenterWindow(boolean center) { *

This setting is used only with LWJGL3, has no effect on fullscreen * windows, and is ignored if the Center Window flag is true. * - * @see #setCenterWindow(boolean) - * * @return the initial position of the window's left edge relative to the * left edge of the desktop + * @see #setCenterWindow(boolean) * @see #setWindowXPosition(int) */ public int getWindowXPosition() { @@ -1404,10 +1403,9 @@ public int getWindowXPosition() { * windows, and is ignored if the Center Window flag is true. Its default * value is 0. * - * @see #setCenterWindow(boolean) - * * @param pos the desired initial position of the window's left edge * relative to the left edge of the desktop + * @see #setCenterWindow(boolean) */ public void setWindowXPosition(int pos) { putInteger("WindowXPosition", pos); @@ -1419,10 +1417,9 @@ public void setWindowXPosition(int pos) { *

This setting is used only with LWJGL3, has no effect on fullscreen * windows, and is ignored if the Center Window flag is true. * - * @see #setCenterWindow(boolean) - * * @return the initial position of the window's upper edge relative to the * upper edge of the desktop + * @see #setCenterWindow(boolean) * @see #setWindowYPosition(int) */ public int getWindowYPosition() { @@ -1436,10 +1433,9 @@ public int getWindowYPosition() { * windows, and is ignored if the Center Window flag is true. Its default * value is 0. * - * @see #setCenterWindow(boolean) - * * @param pos the desired initial position of the window's upper edge * relative to the upper edge of the desktop + * @see #setCenterWindow(boolean) */ public void setWindowYPosition(int pos) { putInteger("WindowYPosition", pos); From aedf2e70ee337305b0f594cdf50dfc33527b1de0 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 13 Dec 2021 21:34:56 -0600 Subject: [PATCH 14/22] TestPostWater issue #1699 Changed it so when you go under water to turn off reverb. I turned off the Low Filter because it is not needed with Reverb is turned off. --- .../src/main/java/jme3test/water/TestPostWater.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index 4f78605f41..d0bf44589b 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -277,14 +277,12 @@ public void simpleUpdate(float tpf) { water.setWaterHeight(initialWaterHeight + waterHeight); if (water.isUnderWater() && !uw) { - waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); + waves.setReverbEnabled(false); uw = true; } if (!water.isUnderWater() && uw) { uw = false; - //waves.setReverbEnabled(false); - waves.setDryFilter(new LowPassFilter(1, 1f)); - //waves.setDryFilter(new LowPassFilter(1,1f)); + waves.setReverbEnabled(true); } } From aad89caec267f9892eae0f8ef65cfb10bfec59fe Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 14 Dec 2021 20:01:36 -0600 Subject: [PATCH 15/22] Added a feature to leave dry filter on/off. Also put on the screen other hot keys this demo supports. --- .../java/jme3test/water/TestPostWater.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index d0bf44589b..ce2f14d085 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -33,6 +33,8 @@ import com.jme3.app.SimpleApplication; import com.jme3.audio.AudioData.DataType; +import com.jme3.font.BitmapFont; +import com.jme3.font.BitmapText; import com.jme3.audio.AudioNode; import com.jme3.audio.LowPassFilter; import com.jme3.input.KeyInput; @@ -74,7 +76,9 @@ public class TestPostWater extends SimpleApplication { private WaterFilter water; private AudioNode waves; final private LowPassFilter aboveWaterAudioFilter = new LowPassFilter(1, 1); - + private boolean useDryFilter = true; + + public static void main(String[] args) { TestPostWater app = new TestPostWater(); app.start(); @@ -183,6 +187,15 @@ public void simpleInitApp() { // viewPort.addProcessor(fpp); + guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); + + setText(0, 50, "1 - Set Foam Texture to Foam.jpg"); + setText(0, 80, "2 - Set Foam Texture to Foam2.jpg"); + setText(0, 110, "3 - Set Foam Texture to Foam3.jpg"); + setText(0, 140, "4 - Turn Dry Filter under water On/Off"); + setText(0, 240, "Page Dwn - Larger Reflection Map"); + setText(0, 270, "Page UP - Smaller Reflection Map"); + inputManager.addListener(new ActionListener() { @Override public void onAction(String name, boolean isPressed, float tpf) { @@ -205,12 +218,18 @@ public void onAction(String name, boolean isPressed, float tpf) { water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32)); System.out.println("Reflection map size : " + water.getReflectionMapSize()); } + if (name.equals("drayFilter")) + { + useDryFilter = !useDryFilter; + } + } } - }, "foam1", "foam2", "foam3", "upRM", "downRM"); + }, "foam1", "foam2", "foam3", "upRM", "downRM", "dryFilter"); inputManager.addMapping("foam1", new KeyTrigger(KeyInput.KEY_1)); inputManager.addMapping("foam2", new KeyTrigger(KeyInput.KEY_2)); inputManager.addMapping("foam3", new KeyTrigger(KeyInput.KEY_3)); + inputManager.addMapping("dryFilter", new KeyTrigger(KeyInput.KEY_4)); inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP)); inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN)); } @@ -277,13 +296,27 @@ public void simpleUpdate(float tpf) { water.setWaterHeight(initialWaterHeight + waterHeight); if (water.isUnderWater() && !uw) { + if (useDryFilter) + waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); + waves.setReverbEnabled(false); uw = true; } if (!water.isUnderWater() && uw) { uw = false; waves.setReverbEnabled(true); + if (useDryFilter) + waves.setDryFilter(new LowPassFilter(1f, 1f)); } } + + protected void setText(int x, int y, String text) { + BitmapText txt2 = new BitmapText(guiFont, false); + txt2.setText(text); + txt2.setLocalTranslation(x, cam.getHeight()-y, 0); + txt2.setColor(ColorRGBA.Red); + guiNode.attachChild(txt2); + + } } From 1f7de77c0639b7d3e2da1015fd691f817d75eaed Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 14 Dec 2021 22:33:17 -0600 Subject: [PATCH 16/22] type preventing input to work correctly. --- jme3-examples/src/main/java/jme3test/water/TestPostWater.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index ce2f14d085..2f9c5272ba 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -218,7 +218,7 @@ public void onAction(String name, boolean isPressed, float tpf) { water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32)); System.out.println("Reflection map size : " + water.getReflectionMapSize()); } - if (name.equals("drayFilter")) + if (name.equals("dryFilter")) { useDryFilter = !useDryFilter; } From cc0547b7f0baf058cf824d9b01737cbe5f68e671 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 3 Jan 2022 00:00:02 -0600 Subject: [PATCH 17/22] more formattings changes. --- .../main/java/jme3test/water/TestPostWater.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index 2f9c5272ba..942e87ddda 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -33,7 +33,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.audio.AudioData.DataType; -import com.jme3.font.BitmapFont; import com.jme3.font.BitmapText; import com.jme3.audio.AudioNode; import com.jme3.audio.LowPassFilter; @@ -187,14 +186,12 @@ public void simpleInitApp() { // viewPort.addProcessor(fpp); - guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); - setText(0, 50, "1 - Set Foam Texture to Foam.jpg"); setText(0, 80, "2 - Set Foam Texture to Foam2.jpg"); setText(0, 110, "3 - Set Foam Texture to Foam3.jpg"); setText(0, 140, "4 - Turn Dry Filter under water On/Off"); - setText(0, 240, "Page Dwn - Larger Reflection Map"); - setText(0, 270, "Page UP - Smaller Reflection Map"); + setText(0, 240, "Pg Dwn - Larger Reflection Map"); + setText(0, 270, "Pg UP - Smaller Reflection Map"); inputManager.addListener(new ActionListener() { @Override @@ -296,17 +293,19 @@ public void simpleUpdate(float tpf) { water.setWaterHeight(initialWaterHeight + waterHeight); if (water.isUnderWater() && !uw) { - if (useDryFilter) + if (useDryFilter) { waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); + } waves.setReverbEnabled(false); - uw = true; + uw = true; } if (!water.isUnderWater() && uw) { uw = false; waves.setReverbEnabled(true); - if (useDryFilter) + if (useDryFilter) { waves.setDryFilter(new LowPassFilter(1f, 1f)); + } } } @@ -314,7 +313,7 @@ public void simpleUpdate(float tpf) { protected void setText(int x, int y, String text) { BitmapText txt2 = new BitmapText(guiFont, false); txt2.setText(text); - txt2.setLocalTranslation(x, cam.getHeight()-y, 0); + txt2.setLocalTranslation(x, cam.getHeight() - y, 0); txt2.setColor(ColorRGBA.Red); guiNode.attachChild(txt2); From f5ab0502db1c7bdb4eb571aa73ef2ce7ecf7e2c1 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 3 Jan 2022 11:52:18 -0800 Subject: [PATCH 18/22] TestPostWater: standardize key names --- jme3-examples/src/main/java/jme3test/water/TestPostWater.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index 942e87ddda..77775b70ad 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -190,8 +190,8 @@ public void simpleInitApp() { setText(0, 80, "2 - Set Foam Texture to Foam2.jpg"); setText(0, 110, "3 - Set Foam Texture to Foam3.jpg"); setText(0, 140, "4 - Turn Dry Filter under water On/Off"); - setText(0, 240, "Pg Dwn - Larger Reflection Map"); - setText(0, 270, "Pg UP - Smaller Reflection Map"); + setText(0, 240, "PgDn - Larger Reflection Map"); + setText(0, 270, "PgUp - Smaller Reflection Map"); inputManager.addListener(new ActionListener() { @Override From 5e1ea297fb78592741c59b533082fe96698fd855 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 3 Jan 2022 11:54:25 -0800 Subject: [PATCH 19/22] TestPostWater: correct key assignements that were swapped --- jme3-examples/src/main/java/jme3test/water/TestPostWater.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index 77775b70ad..59665036d5 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -190,8 +190,8 @@ public void simpleInitApp() { setText(0, 80, "2 - Set Foam Texture to Foam2.jpg"); setText(0, 110, "3 - Set Foam Texture to Foam3.jpg"); setText(0, 140, "4 - Turn Dry Filter under water On/Off"); - setText(0, 240, "PgDn - Larger Reflection Map"); - setText(0, 270, "PgUp - Smaller Reflection Map"); + setText(0, 240, "PgUp - Larger Reflection Map"); + setText(0, 270, "PgDn - Smaller Reflection Map"); inputManager.addListener(new ActionListener() { @Override From 3eee94fb7d37eca904790743841803ac95ecf536 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 3 Jan 2022 11:56:30 -0800 Subject: [PATCH 20/22] TestPostWater: organize imports per the style guide --- jme3-examples/src/main/java/jme3test/water/TestPostWater.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index 59665036d5..2e8d1d0c27 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -33,9 +33,9 @@ import com.jme3.app.SimpleApplication; import com.jme3.audio.AudioData.DataType; -import com.jme3.font.BitmapText; import com.jme3.audio.AudioNode; import com.jme3.audio.LowPassFilter; +import com.jme3.font.BitmapText; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; From cae3fecd9430ef59ec9c32ccdc39f0433c77e4e7 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 3 Jan 2022 12:05:15 -0800 Subject: [PATCH 21/22] TestPostWater: whitespace --- .../java/jme3test/water/TestPostWater.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index 2e8d1d0c27..ce80c2defa 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -76,8 +76,7 @@ public class TestPostWater extends SimpleApplication { private AudioNode waves; final private LowPassFilter aboveWaterAudioFilter = new LowPassFilter(1, 1); private boolean useDryFilter = true; - - + public static void main(String[] args) { TestPostWater app = new TestPostWater(); app.start(); @@ -215,11 +214,9 @@ public void onAction(String name, boolean isPressed, float tpf) { water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32)); System.out.println("Reflection map size : " + water.getReflectionMapSize()); } - if (name.equals("dryFilter")) - { - useDryFilter = !useDryFilter; + if (name.equals("dryFilter")) { + useDryFilter = !useDryFilter; } - } } }, "foam1", "foam2", "foam3", "upRM", "downRM", "dryFilter"); @@ -293,10 +290,10 @@ public void simpleUpdate(float tpf) { water.setWaterHeight(initialWaterHeight + waterHeight); if (water.isUnderWater() && !uw) { - if (useDryFilter) { - waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); - } - + if (useDryFilter) { + waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); + } + waves.setReverbEnabled(false); uw = true; } @@ -304,18 +301,17 @@ public void simpleUpdate(float tpf) { uw = false; waves.setReverbEnabled(true); if (useDryFilter) { - waves.setDryFilter(new LowPassFilter(1f, 1f)); + waves.setDryFilter(new LowPassFilter(1f, 1f)); } } } protected void setText(int x, int y, String text) { - BitmapText txt2 = new BitmapText(guiFont, false); - txt2.setText(text); - txt2.setLocalTranslation(x, cam.getHeight() - y, 0); - txt2.setColor(ColorRGBA.Red); - guiNode.attachChild(txt2); - + BitmapText txt2 = new BitmapText(guiFont, false); + txt2.setText(text); + txt2.setLocalTranslation(x, cam.getHeight() - y, 0); + txt2.setColor(ColorRGBA.Red); + guiNode.attachChild(txt2); } } From 2d17803f73b2ff881ed7b80fb51e60719f9cdbc5 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 3 Jan 2022 14:50:10 -0800 Subject: [PATCH 22/22] TestPostWater: change useDryFilter logic so the 4 key has prompt effect --- .../java/jme3test/water/TestPostWater.java | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java index ce80c2defa..b6444becc4 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWater.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWater.java @@ -34,6 +34,7 @@ import com.jme3.app.SimpleApplication; import com.jme3.audio.AudioData.DataType; import com.jme3.audio.AudioNode; +import com.jme3.audio.Filter; import com.jme3.audio.LowPassFilter; import com.jme3.font.BitmapText; import com.jme3.input.KeyInput; @@ -75,6 +76,7 @@ public class TestPostWater extends SimpleApplication { private WaterFilter water; private AudioNode waves; final private LowPassFilter aboveWaterAudioFilter = new LowPassFilter(1, 1); + final private Filter underWaterAudioFilter = new LowPassFilter(0.5f, 0.1f); private boolean useDryFilter = true; public static void main(String[] args) { @@ -175,12 +177,7 @@ public void simpleInitApp() { waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", DataType.Buffer); waves.setLooping(true); - waves.setReverbEnabled(true); - if (uw) { - waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); - } else { - waves.setDryFilter(aboveWaterAudioFilter); - } + updateAudio(); audioRenderer.playSource(waves); // viewPort.addProcessor(fpp); @@ -288,23 +285,8 @@ public void simpleUpdate(float tpf) { time += tpf; waterHeight = (float) Math.cos(((time * 0.6f) % FastMath.TWO_PI)) * 1.5f; water.setWaterHeight(initialWaterHeight + waterHeight); - if (water.isUnderWater() && !uw) { - - if (useDryFilter) { - waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); - } - - waves.setReverbEnabled(false); - uw = true; - } - if (!water.isUnderWater() && uw) { - uw = false; - waves.setReverbEnabled(true); - if (useDryFilter) { - waves.setDryFilter(new LowPassFilter(1f, 1f)); - } - - } + uw = water.isUnderWater(); + updateAudio(); } protected void setText(int x, int y, String text) { @@ -314,4 +296,31 @@ protected void setText(int x, int y, String text) { txt2.setColor(ColorRGBA.Red); guiNode.attachChild(txt2); } -} + + /** + * Update the audio settings (dry filter and reverb) + * based on boolean fields ({@code uw} and {@code useDryFilter}). + */ + protected void updateAudio() { + Filter newDryFilter; + if (!useDryFilter) { + newDryFilter = null; + } else if (uw) { + newDryFilter = underWaterAudioFilter; + } else { + newDryFilter = aboveWaterAudioFilter; + } + Filter oldDryFilter = waves.getDryFilter(); + if (oldDryFilter != newDryFilter) { + System.out.println("dry filter : " + newDryFilter); + waves.setDryFilter(newDryFilter); + } + + boolean newReverbEnabled = !uw; + boolean oldReverbEnabled = waves.isReverbEnabled(); + if (oldReverbEnabled != newReverbEnabled) { + System.out.println("reverb enabled : " + newReverbEnabled); + waves.setReverbEnabled(newReverbEnabled); + } + } +} \ No newline at end of file