From cc551ca89bf207cafc83e7c8d9b22fd866ec4a26 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 11 Aug 2011 17:56:28 +0200 Subject: 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 --- src/newt/classes/com/jogamp/newt/ScreenMode.java | 27 ++++++++++++++++++++++ .../com/jogamp/newt/util/ScreenModeUtil.java | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src/newt/classes/com/jogamp') 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:
@@ -149,6 +151,22 @@ public class ScreenMode implements Cloneable { public final int getRotation() { return rotation; } + + /** Returns the rotated screen width, + * derived from getMonitorMode().getSurfaceSize().getResolution() + * and getRotation() + */ + public final int getRotatedWidth() { + return getRotatedWH(true); + } + + /** Returns the rotated screen height, + * derived from getMonitorMode().getSurfaceSize().getResolution() + * and getRotation() + */ + 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 screenModePool, - * matching the input modeProperties, or -1 if input could not be processed. + * @return ScreenMode element matching the input modeProperties, + * 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); -- cgit v1.2.3