From b87d3e93f0d0c7dc0101cbcbc5cb487244f46eb5 Mon Sep 17 00:00:00 2001 From: Egor Tsinko Date: Wed, 22 Jan 2020 15:06:57 -0700 Subject: fixed a NPE that happened during offscreen rendering --- src/main/java/org/jogamp/java3d/CanvasViewCache.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jogamp/java3d/CanvasViewCache.java b/src/main/java/org/jogamp/java3d/CanvasViewCache.java index 1edb33e..1532a81 100644 --- a/src/main/java/org/jogamp/java3d/CanvasViewCache.java +++ b/src/main/java/org/jogamp/java3d/CanvasViewCache.java @@ -589,9 +589,11 @@ class CanvasViewCache extends Object { // 0.666x0.666 = 0.444 scaling. This is not a Java3D issue. try { final Graphics2D g2d = (Graphics2D) canvas.getGraphics(); - final AffineTransform t = g2d.getTransform(); - hiDPIXScale = t.getScaleX(); - hiDPIYScale = t.getScaleY(); + if (g2d != null) { + final AffineTransform t = g2d.getTransform(); + hiDPIXScale = t.getScaleX(); + hiDPIYScale = t.getScaleY(); + } } catch (IllegalComponentStateException e) {} metersPerPixelX = screenViewCache.metersPerPixelX; -- cgit v1.2.3