From 84576bc0b7c5bd9b7554ec02f01786228efdbe07 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 May 2013 00:35:08 +0200 Subject: MonitorMode: Fix API doc / comments / names. --- .../classes/com/jogamp/newt/MonitorDevice.java | 30 +++--- src/newt/classes/com/jogamp/newt/MonitorMode.java | 107 +++++++++++---------- src/newt/classes/com/jogamp/newt/Screen.java | 10 +- 3 files changed, 75 insertions(+), 72 deletions(-) (limited to 'src/newt/classes/com/jogamp') diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index fbe4d8cf0..4b0a760a4 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -117,22 +117,26 @@ public abstract class MonitorDevice { } /** - * Return the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization. - * @return original {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * Returns the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization. + *

+ * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + *

*/ public final MonitorMode getOriginalMode() { return originalMode; } /** - * FIXME: May need to support mutable mode, i.e. adding modes on the fly! - * @return the immutable list of {@link MonitorMode}s supported by this monitor. Use w/ care, it's not a copy! + * Returns a list of immutable {@link MonitorMode}s supported by this monitor. + *

+ * Use w/ care, it's not a copy! + *

*/ public final List getSupportedModes() { return supportedModes.getData(); } - /** @return the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ + /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ public final RectangleImmutable getViewport() { return viewport; } @@ -199,24 +203,20 @@ public abstract class MonitorDevice { } /** - * Return the current cached {@link MonitorMode} w/o native query. + * Returns the cached current {@link MonitorMode} w/o native query. *

- * If {@link MonitorMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

- * - * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + *

*/ public final MonitorMode getCurrentMode() { return currentMode; } /** - * Return the current {@link MonitorMode} including a native query. + * Returns the current {@link MonitorMode} resulting from a native query. *

- * If {@link MonitorMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

- * - * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + *

*/ public abstract MonitorMode queryCurrentMode(); diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index e5b329d47..914aa880f 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -29,79 +29,84 @@ package com.jogamp.newt; import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.RectangleImmutable; import javax.media.nativewindow.util.SurfaceSize; +import com.jogamp.newt.util.MonitorModeUtil; -/** Immutable MonitorMode Class, consisting of it's read only components:
+ +/** + * Immutable MonitorMode Class, consisting of it's read only components:
* * * Aquire and filter MonitorMode
* *
* - * Changing ScreenModes
- * FIXME!!!!! + * Changing MonitorMode
* *
- * Example for changing the ScreenMode: + * Example for changing the MonitorMode: *
-        // determine target refresh rate
-        ScreenMode orig = screen.getOriginalScreenMode();
-        int freq = orig.getOutputMode().getRefreshRate();
+        // Pick the monitor:
+        // Either the one used by a window ..
+        MonitorDevice monitor = window.getMainMonitor();
+        
+        // Or arbitrary from the list ..
+        List allMonitor = getMonitorDevices();
+        MonitorDevice monitor = allMonitor.get(0);
 
-        // target resolution
+        // Current and original modes ..
+        MonitorMode mmCurrent = monitor.queryCurrentMode();
+        MonitorMode mmOrig = monitor.getOriginalMode();
+        
+        // Target resolution
         Dimension res = new Dimension(800, 600);
 
-        // target rotation
-        int rot = 0;
-
-        // filter available ScreenModes
-        List screenModes = screen.getScreenModes();
-        screenModes = ScreenModeUtil.filterByRate(screenModes, freq); // get the nearest ones
-        screenModes = ScreenModeUtil.filterByRotation(screenModes, rot);
-        screenModes = ScreenModeUtil.filterByResolution(screenModes, res); // get the nearest ones
-        screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
-
-        // pick 1st one ..
-        screen.setCurrentScreenMode((ScreenMode) screenModes.get(0)); 
- * 
- * - * X11 / AMD just works
- *
- * X11 / NVidia difficulties - *
-    NVidia RANDR RefreshRate Bug
-        If NVidia's 'DynamicTwinView' is enabled, all refresh rates are
-        unique, ie consequent numbers starting with the default refresh, ie 50, 51, ..
-        The only way to workaround it is to disable 'DynamicTwinView'.
-        Read: http://us.download.nvidia.com/XFree86/Linux-x86/260.19.12/README/configtwinview.html
+        // Target refresh rate shall be similar to current one ..
+        float freq = mmCurrent.getRefreshRate();
 
-        Check to see if 'DynamicTwinView' is enable:
-            nvidia-settings -q :0/DynamicTwinview
+        // Target rotation shall be similar to current one
+        int rot = mmCurrent.getRotation();
 
-        To disable it (workaround), add the following option to your xorg.conf device section:
-            Option "DynamicTwinView" "False"
+        // Filter criterias sequential out of all available MonitorMode of the chosen MonitorDevice
+        List monitorModes = monitor.getSupportedModes();
+        monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
+        monitorModes = MonitorModeUtil.filterByRotation(monitorModes, rot);
+        monitorModes = MonitorModeUtil.filterByResolution(monitorModes, res);
+        monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq);        
+        monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
 
-    NVidia RANDR Rotation:
-        To enable it, add the following option to your xorg.conf device section:
-            Option "RandRRotation" "on"
+        // pick 1st one and set to current ..
+        MonitorMode mm = monitorModes.get(0);
+        monitor.setCurrentMode(mm);
  * 
- * */ public class MonitorMode { /** @@ -113,8 +118,11 @@ public class MonitorMode { * */ public static class SizeAndRRate { + /** Non rotated surface size */ public final SurfaceSize surfaceSize; + /** Vertical refresh rate */ public final float refreshRate; + /** Mode bitfield flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ public final int flags; public final int hashCode; @@ -262,6 +270,7 @@ public class MonitorMode { return sizeAndRRate.surfaceSize; } + /** Returns the vertical refresh rate. */ public final float getRefreshRate() { return sizeAndRRate.refreshRate; } diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 81a62d898..f56aff964 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -163,18 +163,12 @@ public abstract class Screen { public abstract String getFQName(); /** - * Return a list of all available {@link MonitorMode}s for all {@link MonitorDevice}s. - *

- * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

+ * Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s. */ public abstract List getMonitorModes(); /** - * Return a list of all available {@link MonitorDevice}s. - *

- * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

+ * Return a list of available {@link MonitorDevice}s. */ public abstract List getMonitorDevices(); -- cgit v1.2.3