aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java22
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java21
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java10
3 files changed, 45 insertions, 8 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
index 8e5d305dd..a65675204 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
@@ -34,6 +34,7 @@ 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 com.jogamp.common.util.ArrayHashSet;
/**
@@ -124,29 +125,34 @@ public abstract class MonitorDevice {
}
/**
- * Stores the <i>pixels per millimeter</i> value according to <i>current</i> {@link MonitorMode}
- * {@link SurfaceSize#getResolution() SurfaceSize's resolution} in the given storage <code>ppmmStore</code>.
+ * Returns the <i>pixels per millimeter</i> value according to the <i>current</i> {@link MonitorMode mode}'s
+ * {@link SurfaceSize#getResolution() surface resolution}.
* <p>
* To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>.
* </p>
+ * @param ppmmStore float[2] storage for the ppmm result
+ * @return the passed storage containing the ppmm for chaining
*/
- public final void getPixelsPerMM(final float[] ppmmStore) {
- final MonitorMode mode = getCurrentMode();
- getPixelsPerMM(mode, ppmmStore);
+ public final float[] getPixelsPerMM(final float[] ppmmStore) {
+ return getPixelsPerMM(getCurrentMode(), ppmmStore);
}
/**
- * Stores the <i>pixels per millimeter</i> value according to the given {@link MonitorMode}
- * {@link SurfaceSize#getResolution() SurfaceSize's resolution} in the given storage <code>ppmmStore</code>.
+ * Returns the <i>pixels per millimeter</i> value according to the given {@link MonitorMode mode}'s
+ * {@link SurfaceSize#getResolution() surface resolution}.
* <p>
* To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>.
* </p>
+ * @param mode
+ * @param ppmmStore float[2] storage for the ppmm result
+ * @return the passed storage containing the ppmm for chaining
*/
- public final void getPixelsPerMM(final MonitorMode mode, final float[] ppmmStore) {
+ public final float[] getPixelsPerMM(final MonitorMode mode, final float[] ppmmStore) {
final DimensionImmutable sdim = getSizeMM();
final DimensionImmutable spix = mode.getSurfaceSize().getResolution();
ppmmStore[0] = (float)spix.getWidth() / (float)sdim.getWidth();
ppmmStore[1] = (float)spix.getHeight() / (float)sdim.getHeight();
+ return ppmmStore;
}
/**
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 08236ae67..600ecee52 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -49,6 +49,7 @@ import javax.media.nativewindow.ScalableSurface;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
+import javax.media.nativewindow.util.SurfaceSize;
/**
* Specifying NEWT's Window functionality:
@@ -254,6 +255,26 @@ public interface Window extends NativeWindow, WindowClosingProtocol, ScalableSur
Rectangle getBounds();
/**
+ * Returns the <i>pixels per millimeter</i> of this window's {@link NativeSurface}
+ * according to the {@link #getMainMonitor() main monitor}'s <i>current</i> {@link MonitorMode mode}'s
+ * {@link SurfaceSize#getResolution() surface resolution}.
+ * <p>
+ * Method takes the {@link #getCurrentSurfaceScale(int[]) current surface-scale} and {@link #getNativeSurfaceScale(int[]) native surface-scale}
+ * into account, i.e.:
+ * <pre>
+ * surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale,
+ * with PpMM == pixel per millimeter
+ * </pre>
+ * </p>
+ * <p>
+ * To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>.
+ * </p>
+ * @param ppmmStore float[2] storage for the ppmm result
+ * @return the passed storage containing the ppmm for chaining
+ */
+ float[] getPixelsPerMM(final float[] ppmmStore);
+
+ /**
* Sets the size of the window's client area in window units, excluding decorations.
*
* <p>
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 2991bb98a..cdc4f1217 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -404,6 +404,16 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
+ public final int[] getNativeSurfaceScale(final int[] result) {
+ return window.getNativeSurfaceScale(result);
+ }
+
+ @Override
+ public final float[] getPixelsPerMM(final float[] ppmmStore) {
+ return window.getPixelsPerMM(ppmmStore);
+ }
+
+ @Override
public final void setPosition(int x, int y) {
window.setPosition(x, y);
}