aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-11 17:56:28 +0200
committerSven Gothel <[email protected]>2011-08-11 17:56:28 +0200
commitcc551ca89bf207cafc83e7c8d9b22fd866ec4a26 (patch)
tree4e92726244aa436c2d27a0a71f6ad37f0a026e0c /src/newt/classes/com
parentb893ada668591187ac6866296439811036db2d95 (diff)
NEWT/Android Fix: Display/Screen/Window creation ; ScreenMode Change
- Remove Application Context notion in Screen/Display, use 'jogamp.common.os.android.StaticContext' - Display, Screen and Window construction is Android agnostic allowing simple GLWindow creation. - Android ScreenMode Fix: - Use unrotated screen dimension - Intercept 'orientation' configChange, which keeps running the application in case of a rotation. - ScreenMode Add: getRotatedWidth() / getRotatedHeight(), used for Screen.setScreenSize(..) which reflects the rotates dimension. - ScreenMode: getCurrentMode() allows new, not yet detected, ScreenModes
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r--src/newt/classes/com/jogamp/newt/ScreenMode.java27
-rw-r--r--src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java4
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);