More lenient non-fullscreen display mode behavior

Presently, JME rejects any request to set a non-full screen display mode to anything but the legal set of full screen display modes. This seems overly restrictive, particularly as I’ve discovered that Linux running in Xinerama mode happily reports only a single display mode the size of the entire multi-monitor screen which is rarely desirable, especially in windowed mode.



I propose the following patch:

Index: src/com/jme/system/lwjgl/LWJGLDisplaySystem.java
===================================================================
RCS file: /cvs/jme/src/com/jme/system/lwjgl/LWJGLDisplaySystem.java,v
retrieving revision 1.26
diff -u -p -r1.26 LWJGLDisplaySystem.java
--- src/com/jme/system/lwjgl/LWJGLDisplaySystem.java    4 Jun 2005 22:52:44 -0000       1.26
+++ src/com/jme/system/lwjgl/LWJGLDisplaySystem.java    24 Jun 2005 23:45:36 -0000
@@ -589,9 +589,14 @@ public class LWJGLDisplaySystem extends
      */
     private void reinitDisplay() {
         // create the Display.
-        DisplayMode mode = getValidDisplayMode(width, height, bpp, frq);
-        if (null == mode) {
-            throw new JmeException("Bad display mode");
+        DisplayMode mode;
+        if (fs) {
+            mode = getValidDisplayMode(width, height, bpp, frq);
+            if (null == mode) {
+                throw new JmeException("Bad display mode");
+            }
+        } else {
+            mode = new DisplayMode(width, height);
         }
 
         try {


If a full screen display mode is requested, it validates it as usual, but if a non-full screen mode is requested, it simply passes it on unchecked to LWJGL. This also allows non-standard windowed mode resolutions (like 1000x500 or whatever else you might dream up if you're thinking outside the box).

Implemented and checked in.

It turns out that an additional modification is needed for initDisplay() which is called the first time. We only got reinitDisplay() with the previous patch:


Index: code/system/lwjgl/LWJGLDisplaySystem.java
===================================================================
RCS file: /cvs/jme/src/com/jme/system/lwjgl/LWJGLDisplaySystem.java,v
retrieving revision 1.29
diff -u -p -r1.29 LWJGLDisplaySystem.java
--- code/system/lwjgl/LWJGLDisplaySystem.java   15 Sep 2005 17:14:43 -0000      1.29
+++ code/system/lwjgl/LWJGLDisplaySystem.java   27 Sep 2005 01:46:10 -0000
@@ -507,7 +507,15 @@ public class LWJGLDisplaySystem extends
      */
     private void initDisplay() {
         // create the Display.
-        DisplayMode mode = getValidDisplayMode(width, height, bpp, frq);
+        DisplayMode mode;
+        if (fs) {
+            mode = getValidDisplayMode(width, height, bpp, frq);
+            if (null == mode) {
+                throw new JmeException("Bad display mode");
+            }
+        } else {
+            mode = new DisplayMode(width, height);
+        }
         PixelFormat format = new PixelFormat(bpp, alphaBits, depthBits,
                 stencilBits, samples);
         if (null == mode) {



It may be worthwhile to try to make initDisplay() use reinitDisplay() or pull the shared code into a single method called by both.

Thanks for pointing this out.  It's fixed in cvs.