aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-23 18:15:00 +0200
committerSven Gothel <[email protected]>2011-10-23 18:15:00 +0200
commit2a00f1008e2be44e02e7b96f3b1cb6af210597f2 (patch)
tree8798d08b15f29fb174b36dbea98812ce103c96bf /src/newt/classes/jogamp
parent610473bd1ad7598db42d40d0d861467bdb1304b6 (diff)
NEWT/ScreenMode: Make getCurrenctScreenMode..() more fail proof in case the (native) impl. doesn't work.
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 61764196f..9c51fe973 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -311,7 +311,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
if(null == sms) {
throw new InternalError("ScreenModeStatus.getScreenModeStatus("+this.getFQName()+") == null");
}
- ScreenMode sm0 = getCurrentScreenModeImpl();
+ ScreenMode sm0 = getCurrentScreenModeIntern();
if(null == sm0) {
throw new InternalError("getCurrentScreenModeImpl() == null");
}
@@ -453,21 +453,32 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
/**
* To be implemented by the native specification.<br>
* Is called within a thread safe environment.<br>
- * Default dummy implementation only set the current screen size, other values are dummy defaults.<br>
*/
protected ScreenMode getCurrentScreenModeImpl() {
- int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL];
- int i = 0;
- props[i++] = 0; // set later for verification of iterator
- props[i++] = getWidth(); // width
- props[i++] = getHeight(); // height
- props[i++] = 32; // bpp
- props[i++] = 519; // widthmm
- props[i++] = 324; // heightmm
- props[i++] = 60; // rate
- props[i++] = 0; // rot
- props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count
- return ScreenModeUtil.streamIn(props, 0);
+ return null;
+ }
+
+ /**
+ * Utilizes {@link #getCurrentScreenModeImpl()}, if the latter returns null it uses
+ * the current screen size and dummy values.
+ */
+ protected ScreenMode getCurrentScreenModeIntern() {
+ ScreenMode res = getCurrentScreenModeImpl();
+ if(null == res) {
+ int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL];
+ int i = 0;
+ props[i++] = 0; // set later for verification of iterator
+ props[i++] = getWidth(); // width
+ props[i++] = getHeight(); // height
+ props[i++] = 32; // bpp
+ props[i++] = 519; // widthmm
+ props[i++] = 324; // heightmm
+ props[i++] = 60; // rate
+ props[i++] = 0; // rot
+ props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count
+ res = ScreenModeUtil.streamIn(props, 0);
+ }
+ return res;
}
/**
@@ -485,7 +496,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
if(null==sms) {
IntIntHashMap screenModesIdx2NativeIdx = new IntIntHashMap();
- final ScreenMode currentSM = getCurrentScreenModeImpl();
+ final ScreenMode currentSM = getCurrentScreenModeIntern();
if(null == currentSM) {
throw new InternalError("getCurrentScreenModeImpl() == null");
}