Need more resolutions to choose from when using dual screens

I have 2 monitors both running at 1280x1024@75Hz using twinview. And currently, when running things built on SimpleGame, I have no way of getting a window small enough to either fit on one screen or allow me to see the fps counter. This is somewhat annoying. :smiley:



I'd like to have options like 800x600 but my only choices are 1920x1024@53Hz, 2080x1024@52Hz, 2304x1024@51Hz and 2560x1024@50Hz. (Also the refresh-rates are all wrong, but that might be a nvidia thing?)



Is this something to workaround in jME or should it rather be fixed on the lwjgl side?



Ideally, it'd also be nice to have the option of running fullscreen on only one screen instead of both. :slight_smile: Is there any support for that?

We use the card's reported supported fullscreen dimensions as options, but in windowed mode it could really be any non 0 dimensions.  (might also need to be smaller than your current display settings)  Picking what abstract dimensions to add to that screen (by default) and making everyone happy is the problem.  It should probably read those from a config file when you don't have fullscreen checked.

Perhaps there could be 2 lists of available resolutions, one with the probed fullscreen resolutions and one for windowed with some fixed selection of standard resolutions like 800x600 etc?



The lists could be switched whenever the fullscreen button is toggled, just like the bpp and Hz lists are changed when a new resolution is selected.



(I also assume the refresh rate option could be disabled when fullscreen is not selected. But how about bit depth?)





If this sounds like a good idea then I might take a stab at producing a patch, given that I find some free time, coffee, inspiration and so on. :slight_smile:

Exactly what I was referring to.  If you have the time, go for it! :slight_smile:

would be wonderful, we have the same problem, with a multi view giving foobar resolution optionsā€¦

Well, here we go then! :smiley:



This patch shows 4 default resolutions when fullscreen is not selected. It is a small patch so perhaps I don't have to explain what it does in detailā€¦ :slight_smile:



Worth to note is that for windowed the color depth choice is fixed to 24 and 16 (no 32) and the display frequency that gets saved is -1. (I think that's ok though, as it is only used to find the best matching frequency when actually opening the display?)



Anyone missing a favourite resolution or 32 bpp? Do we need more code to remove windowed resolutions that won't fit on the screen?


Index: src/com/jme/system/lwjgl/LWJGLPropertiesDialog.java
===================================================================
RCS file: /cvs/jme/src/com/jme/system/lwjgl/LWJGLPropertiesDialog.java,v
retrieving revision 1.15
diff -u -r1.15 LWJGLPropertiesDialog.java
--- src/com/jme/system/lwjgl/LWJGLPropertiesDialog.java   17 Aug 2007 10:34:28 -0000   1.15
+++ src/com/jme/system/lwjgl/LWJGLPropertiesDialog.java   29 Nov 2007 16:49:12 -0000
@@ -94,6 +94,10 @@
     // Array of supported display modes
     private DisplayMode[] modes = null;
 
+    // Array of windowed resolutions
+    private String[] windowedResolutions = { "640 x 480", "800 x 600",
+            "1024 x 768", "1152 x 864" };
+
     // UI components
     private JCheckBox fullscreenBox = null;
 
@@ -257,10 +261,15 @@
         displayFreqCombo.addKeyListener(aListener);
         fullscreenBox = new JCheckBox("Fullscreen?");
         fullscreenBox.setSelected(source.getFullscreen());
+        fullscreenBox.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                updateResolutionChoices();
+            }
+        });
         rendererCombo = setUpRendererChooser();
         rendererCombo.addKeyListener(aListener);
 
-        updateDisplayChoices();
+        updateResolutionChoices();
 
         optionsPanel.add(displayResCombo);
         optionsPanel.add(colorDepthCombo);
@@ -310,6 +319,7 @@
      */
     private boolean verifyAndSaveCurrentSelection() {
         String display = (String) displayResCombo.getSelectedItem();
+        boolean fullscreen = fullscreenBox.isSelected();
 
         int width = Integer.parseInt(display.substring(0, display
                 .indexOf(" x ")));
@@ -321,10 +331,11 @@
                 .indexOf(" ")));
 
         String freqString = (String) displayFreqCombo.getSelectedItem();
-        int freq = Integer.parseInt(freqString.substring(0, freqString
-                .indexOf(" ")));
+        int freq = -1;
+        if (fullscreen)
+            freq = Integer.parseInt(freqString.substring(0, freqString
+                    .indexOf(" ")));
 
-        boolean fullscreen = fullscreenBox.isSelected();
         // FIXME: Does not work in Linux
         /*
          * if (!fullscreen) { //query the current bit depth of the desktop int
@@ -337,10 +348,12 @@
 
         String renderer = (String) rendererCombo.getSelectedItem();
 
-        // test valid display mode
+        // test valid display mode but only use when going fullscreen
         DisplaySystem disp = DisplaySystem.getDisplaySystem(renderer);
         boolean valid = (disp != null) ? disp.isValidDisplayMode(width, height,
                 depth, freq) : false;
+        if (!fullscreen)
+            valid = true;
 
         if (valid)
             // use the PropertiesIO class to save it.
@@ -390,7 +403,15 @@
         return nameBox;
     }
 
+    /**
+     * <code>updateDisplayChoices</code> updates the available color depth and
+     * display frequency options to match the currently selected resolution.
+     */
     private void updateDisplayChoices() {
+        if (!fullscreenBox.isSelected()) {
+            // don't run this function when changing windowed settings
+            return;
+        }
         String resolution = (String) displayResCombo.getSelectedItem();
         // grab available depths
         String[] depths = getDepths(resolution, modes);
@@ -402,6 +423,29 @@
         displayFreqCombo.setSelectedItem(source.getFreq() + " Hz");
     }
 
+    /**
+     * <code>updateResolutionChoices</code> updates the available resolutions
+     * list to match the currently selected window mode (fullscreen or
+     * windowed). It then sets up a list of standard options (if windowed) or
+     * calls <code>updateDisplayChoices</code> (if fullscreen).
+     */
+    private void updateResolutionChoices() {
+        if (!fullscreenBox.isSelected()) {
+            displayResCombo.setModel(new DefaultComboBoxModel(
+                    windowedResolutions));
+            colorDepthCombo.setModel(new DefaultComboBoxModel(new String[] {
+                    "24 bpp", "16 bpp" }));
+            displayFreqCombo.setModel(new DefaultComboBoxModel(
+                    new String[] { "n/a" }));
+            displayFreqCombo.setEnabled(false);
+        } else {
+            displayResCombo.setModel(new DefaultComboBoxModel(
+                    getResolutions(modes)));
+            displayFreqCombo.setEnabled(true);
+            updateDisplayChoices();
+        }
+    }
+
     //
     // Utility methods
     //

I'd say that 1280 x 1024 is a very usual resolution, and nowadays there is even the 1600 x 1280

Yes, 1280x1024 is very common. But do enough people use a resolution so large that they'd want to have a window the size of 1280x1024?

If yes, then think we/I should also add some code to remove default window resolutions too large for the window to fit on the screen.

If you ask, then the answer would be, of courseā€¦ the more it solves, the betterā€¦  :smiley: (as long as it is not me writing the code  :wink: )

In.