diff options
author | Sven Gothel <[email protected]> | 2014-10-09 01:59:33 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-10-09 01:59:33 +0200 |
commit | 39bed561a04dab457663aaa651e9c9f1f7c12270 (patch) | |
tree | a20ee180a314eeb1d61564bfc12af38483f79591 | |
parent | 1d623bfc9db124414f6b64a0ce72308c7757b049 (diff) |
Newt Screen viewport in windows units: Add missing setup in overriden calcVirtualScreenOriginAndSize(..) method (duplicate pixel unit)
8 files changed, 30 insertions, 0 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index acc7b722d..c30968c4b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -76,6 +76,12 @@ public class Rectangle implements Cloneable, RectangleImmutable { this.width = width; this.height = height; } + public final void set(final Rectangle s) { + this.x = s.x; + this.y = s.y; + this.width = s.width; + this.height = s.height; + } public final void setX(final int x) { this.x = x; } public final void setY(final int y) { this.y = y; } public final void setWidth(final int width) { this.width = width; } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index fab3fe882..2cd47313a 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -110,6 +110,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, fixedWidth, fixedHeight); // FIXME + viewportInWindowUnits.set(viewport); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index e3e854cba..64cae75f6 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -103,6 +103,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, cachedWidth, cachedHeight); + viewportInWindowUnits.set(viewport); } /** Called from {@link #initNative()}. */ diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index b5400c386..2ce835c52 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -112,6 +112,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, cachedWidth, cachedHeight); + viewportInWindowUnits.set(viewport); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index 71f8b1439..d4113561a 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -108,6 +108,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, cachedWidth, cachedHeight); + viewportInWindowUnits.set(viewport); } protected void sizeChanged(final int w, final int h) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index 1cba421bc..38acd03ae 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -158,6 +158,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(getVirtualOriginX0(), getVirtualOriginY0(), getVirtualWidthImpl0(), getVirtualHeightImpl0()); + viewportInWindowUnits.set(viewport); } // Native calls diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 1d779741a..f7361740e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -246,6 +246,7 @@ public class ScreenDriver extends ScreenImpl { @Override public Object run(final long dpy) { viewport.set(0, 0, getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx)); + viewportInWindowUnits.set(viewport); return null; } } ); if( DEBUG ) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java index 68a08b8de..860560658 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.newt.mm; import java.io.IOException; + import javax.media.nativewindow.NativeWindowFactory; import org.junit.Assert; @@ -48,9 +49,11 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.Iterator; import java.util.List; + import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; import javax.media.nativewindow.util.SurfaceSize; import javax.media.opengl.GLProfile; @@ -192,6 +195,21 @@ public class TestScreenMode00aNEWT extends UITestCase { Assert.assertNotNull(sm_c); Assert.assertEquals(sm_o, sm_c); } + + final RectangleImmutable zero = new Rectangle(); + + final Rectangle monitorViewPU = new Rectangle(); + final Rectangle monitorViewWU = new Rectangle(); + MonitorDevice.unionOfViewports(monitorViewPU, monitorViewWU, monitors); + System.err.println("Test.0: Monitor union viewport: "+monitorViewPU+" [pu] / "+monitorViewWU+" [wu]"); + Assert.assertNotEquals(zero, monitorViewPU); + Assert.assertNotEquals(zero, monitorViewWU); + + final RectangleImmutable screenViewPU = screen.getViewport(); + final RectangleImmutable screenViewWU = screen.getViewportInWindowUnits(); + System.err.println("Test.1: Screen viewport: "+screenViewPU+" [pu] / "+screenViewWU+" [wu]"); + Assert.assertNotEquals(zero, screenViewPU); + Assert.assertNotEquals(zero, screenViewWU); screen.removeReference(); |