diff options
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/ScreenMode.java | 27 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java | 4 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/newt/classes/com/jogamp/newt/ScreenMode.java b/src/newt/classes/com/jogamp/newt/ScreenMode.java index 81ce70249..2a05d842e 100644 --- a/src/newt/classes/com/jogamp/newt/ScreenMode.java +++ b/src/newt/classes/com/jogamp/newt/ScreenMode.java @@ -28,6 +28,8 @@ package com.jogamp.newt; +import javax.media.nativewindow.util.DimensionReadOnly; + import com.jogamp.newt.util.MonitorMode; /** Immutable ScreenMode Class, consisting of it's read only components:<br> @@ -149,6 +151,22 @@ public class ScreenMode implements Cloneable { public final int getRotation() { return rotation; } + + /** Returns the rotated screen width, + * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> + * and <code>getRotation()</code> + */ + public final int getRotatedWidth() { + return getRotatedWH(true); + } + + /** Returns the rotated screen height, + * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> + * and <code>getRotation()</code> + */ + public final int getRotatedHeight() { + return getRotatedWH(false); + } public final String toString() { return "[ " + getMonitorMode() + ", " + rotation + " degr ]"; @@ -186,4 +204,13 @@ public class ScreenMode implements Cloneable { hash = ((hash << 5) - hash) + getRotation(); return hash; } + + private final int getRotatedWH(boolean width) { + final DimensionReadOnly d = getMonitorMode().getSurfaceSize().getResolution(); + final boolean swap = ScreenMode.ROTATE_90 == rotation || ScreenMode.ROTATE_270 == rotation ; + if ( ( width && swap ) || ( !width && !swap ) ) { + return d.getHeight(); + } + return d.getWidth(); + } } diff --git a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java index 3e0e3dac5..9c4993f1d 100644 --- a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java @@ -244,8 +244,8 @@ public class ScreenModeUtil { * * @param modeProperties the input data * @param offset the offset to the input data - * @return index of the identical (old or new) ScreenMode element in <code>screenModePool</code>, - * matching the input <code>modeProperties</code>, or -1 if input could not be processed. + * @return ScreenMode element matching the input <code>modeProperties</code>, + * or null if input could not be processed. */ public static ScreenMode streamIn(int[] modeProperties, int offset) { return streamInImpl(null, null, null, null, null, modeProperties, offset); |