From 84576bc0b7c5bd9b7554ec02f01786228efdbe07 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
+ *
+ * Use w/ care, it's not a copy!
+ *
- * 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.
- * 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:rotation
, measured counter clockwise (CCW)- // 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- * - * X11 / AMD just worksallMonitor = 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)); - *
- 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- * */ 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. - *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); *
- * 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- * 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