0

I have a Java/Swing/Java3D/JOGAMP JOGL/ app where a set of X-Y-Z sliders control the 3D viewer location. It runs well on the MacOS (10.11). However, when run under Windows 10 (64-bit), the 3DCanvas region of the screen is sometimes overwritten with blank gray.

I use a black background for the Canvas3D, and the default double buffering.

Someone suggested testing with a minimalist app, and I replicated the SAME PROBLEM USING "PyramidEample.java" code example from Java3D.org (posted below)

Here's what I'm seeing in Windows-10 (64-bit):

1) The bug occurs when iconizing the app down to the dock, and then re-iflating the window (de-iconizing). As the app window inflates, you see the correct image in the Canvas3D region for a fraction of a second then it is covered over or replaced by flat grey (same color as the background for the slider controls).

If I drag a slider, the Canvas3D resumes showing the 3D content. I've never seen the grey cover after the Swing mouse-handler processes one of the app sliders.

2) When I drag the app window sideways off screen, and then reverse and drag it back, the Canvas3D portion flickers between normal image and flat grey. At the end of the drag (app fully enclosed in screen), the final Canvas3D region is unpredictable....it could be drawn normal vs. flat grey on the mouse-release of the window bar.

3) Sleep-Unsleep. If I have my app in the foreground and sleep the Win laptop, when I wake it back up, my app shows flat gray where the Canvas3D should draw. Video Clip demonstrating what bug looks like

What I've tried:

1) A double-buffering issue? I tried setting the Canvas3D to disable double-buffering, but it had not effect.

2) I put code in the app's WindowListener's "windowDeiconified(event)" method that forces a Canvas3D repaint, but that did nothing.

3) Since the bug is platform-dependent, I tried all the possible "system look and feel" options, but that did not fix the problem.

Since a very simplistic test app exhibits the 3D graphics bug, it would help if you could narrow it down to the Java3D run-time environmental variable: 1) If run using the older Oracle Java3D (JRE 1.8.0_22 or earlier), instead of the JOGAMP 1.6.0 replacement stack, do you see the bug shown in the vid?
2) Whatever Java3D stack you run on, it would be helpful to know if you can see this bug.

Java compiler: 1.8 Java JDK-JRE: 1.8.0_102 Java 3D: JOGAMP: 3D [dev] 1.6.0-pre12-daily-experimental daily OS: Windows 10 Pro (64-bit) Test computer: Dell laptop E6500 w/ NVIDIA Quadro NVS 160M card (driver 9.18.13.4192)

import java.awt.Color;
import com.sun.j3d.utils.geometry.GeometryInfo;
import com.sun.j3d.utils.geometry.NormalGenerator;
import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.media.j3d.*;
import javax.vecmath.*;

// An Egyptian pyramid
// Base divided into two triangles

public class PyramidExample {
   public static void main(String[] args) {
    SimpleUniverse universe = new SimpleUniverse();
    BranchGroup group = new BranchGroup();

    Point3f e = new Point3f(1.0f, 0.0f, 0.0f); // east
    Point3f s = new Point3f(0.0f, 0.0f, 1.0f); // south
    Point3f w = new Point3f(-1.0f, 0.0f, 0.0f); // west
    Point3f n = new Point3f(0.0f, 0.0f, -1.0f); // north
    Point3f t = new Point3f(0.0f, 0.721f, 0.0f); // top

    TriangleArray pyramidGeometry = new TriangleArray(18,
            TriangleArray.COORDINATES);
    pyramidGeometry.setCoordinate(0, e);
    pyramidGeometry.setCoordinate(1, t);
    pyramidGeometry.setCoordinate(2, s);

    pyramidGeometry.setCoordinate(3, s);
    pyramidGeometry.setCoordinate(4, t);
    pyramidGeometry.setCoordinate(5, w);

    pyramidGeometry.setCoordinate(6, w);
    pyramidGeometry.setCoordinate(7, t);
    pyramidGeometry.setCoordinate(8, n);

    pyramidGeometry.setCoordinate(9, n);
    pyramidGeometry.setCoordinate(10, t);
    pyramidGeometry.setCoordinate(11, e);

    pyramidGeometry.setCoordinate(12, e);
    pyramidGeometry.setCoordinate(13, s);
    pyramidGeometry.setCoordinate(14, w);

    pyramidGeometry.setCoordinate(15, w);
    pyramidGeometry.setCoordinate(16, n);
    pyramidGeometry.setCoordinate(17, e);
    GeometryInfo geometryInfo = new GeometryInfo(pyramidGeometry);
    NormalGenerator ng = new NormalGenerator();
    ng.generateNormals(geometryInfo);

    GeometryArray result = geometryInfo.getGeometryArray();

    // yellow appearance
    Appearance appearance = new Appearance();
    Color3f color = new Color3f(Color.yellow);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Texture texture = new Texture2D();
    TextureAttributes texAttr = new TextureAttributes();
    texAttr.setTextureMode(TextureAttributes.MODULATE);
    texture.setBoundaryModeS(Texture.WRAP);
    texture.setBoundaryModeT(Texture.WRAP);
    texture.setBoundaryColor(new Color4f(0.0f, 1.0f, 0.0f, 0.0f));
    Material mat = new Material(color, black, color, white, 70f);
    appearance.setTextureAttributes(texAttr);
    appearance.setMaterial(mat);
    appearance.setTexture(texture);
    Shape3D shape = new Shape3D(result, appearance);
    group.addChild(shape);

    // above pyramid
    Vector3f viewTranslation = new Vector3f();
    viewTranslation.z = 3;
    viewTranslation.x = 0f;
    viewTranslation.y = .3f;
    Transform3D viewTransform = new Transform3D();
    viewTransform.setTranslation(viewTranslation);
    Transform3D rotation = new Transform3D();
    rotation.rotX(-Math.PI / 12.0d);
    rotation.mul(viewTransform);
    universe.getViewingPlatform().getViewPlatformTransform().setTransform(
            rotation);
    universe.getViewingPlatform().getViewPlatformTransform().getTransform(
            viewTransform);

    // lights
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
            1000.0);
    Color3f light1Color = new Color3f(.7f, .7f, .7f);
    Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color,   
 light1Direction);
    light1.setInfluencingBounds(bounds);
    group.addChild(light1);
    Color3f ambientColor = new Color3f(.4f, .4f, .4f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    group.addChild(ambientLightNode);

    universe.addBranchGraph(group);
  }
}
pbierre
  • 276
  • 1
  • 8
  • Can you post an [MCVE](http://stackoverflow.com/help/mcve) that demonstrates the problem? – copeg Aug 08 '16 at 22:39
  • Could you post also a couple of images? – elect Aug 09 '16 at 06:41
  • I've posted a video that shows what the bug looks like. I'm relieved that a very simple, minimalist Java3D test app (PyramidExample) demonstrates the same bug. It should now be easier to pin the problem down to either the Java3D run-time stack I'm using (e.g. JOGAMP vs. Oracle 1.8.0_22), or something more specific to the test computer and GPU I'm running on. I only have 1 Windows platform to test on, so it would help to get feedback from Win platforms. – pbierre Aug 11 '16 at 00:23
  • Java3D 1.5.2 demonstrates SAME BUG. I installed 1.5.2 (the J3D last managed by the Java3D.net group). I compiled the PyramidExample app to run on the 1.5.2 stack. I get the same bug. Now that I've ruled out JOGAMP J3D 1.6.0 as the problem (which is only a couple of years old), the attention turns to something specific about my Dell Win64 laptop. Can someone with a different Win64 platform run the PyramidExample app, and get back with the window-deflate-inflate results? – pbierre Aug 11 '16 at 20:59
  • Excellent video, but unfortunately the only thing I can do is suggesting you to try to open a thread also [here](http://forum.jogamp.org/java3d-f3728156.html) – elect Aug 15 '16 at 10:17
  • I still don't have enough run-platform info to post a bug on Java3D. If you could take the time to run the attached "PyramidExample" app on a Windows computer, I need to know what run platform factors to cite in the bug report. Is it specific to Win64? Win10 (64)? A specific GPU implementation (NVIDIA??). The next step to figuring this out is finding a Win platform that DOESN'T demonstrate the problem. Can you help? – pbierre Aug 16 '16 at 16:44

1 Answers1

0

Sorry for this old replay.

Add the following to your main class:

 static {
        // in JRE 7 from causing redraw problems (i.e. the Java 3D canvas is sometimes
        // drawn as a blank gray rectangle).      
        System.setProperty("sun.awt.noerasebackground", "true");    
    }

Your full code, this time with a JFrame and Canvas instead of default SimpleUniverse's internal frame:

package test;

import java.awt.*;
import com.sun.j3d.utils.geometry.GeometryInfo;
import com.sun.j3d.utils.geometry.NormalGenerator;
import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.media.j3d.*;
import javax.swing.*;
import javax.vecmath.*;



// An Egyptian pyramid
// Base divided into two triangles

public class PyramidExample {

    static {
        // in JRE 7 from causing redraw problems (i.e. the Java 3D canvas is sometimes
        // drawn as a blank gray rectangle).      
        System.setProperty("sun.awt.noerasebackground", "true");    
    }

    /**
     * Main method
     * @param args
     */
   public static void main(String[] args) {
    JFrame frame = new JFrame("Pyramid Example");
    frame.setSize(800, 600);
    frame.setLayout(new BorderLayout());    
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout());

    // get default configuration for 3D
    GraphicsConfiguration conf =   SimpleUniverse.getPreferredConfiguration();
    Canvas3D canvas = new Canvas3D(conf);
    // create simpleUniverse       
    SimpleUniverse universe = new SimpleUniverse(canvas);
    BranchGroup scene = createScene(universe);
    universe.addBranchGraph(scene);

    mainPanel.add(canvas, BorderLayout.CENTER);
    frame.setVisible(true);
   }

   /**
    * Create Scene graph
    * @param universe
    * @return
    */
  private static  BranchGroup createScene(SimpleUniverse universe) { 
    BranchGroup group = new BranchGroup();

    Point3f e = new Point3f(1.0f, 0.0f, 0.0f); // east
    Point3f s = new Point3f(0.0f, 0.0f, 1.0f); // south
    Point3f w = new Point3f(-1.0f, 0.0f, 0.0f); // west
    Point3f n = new Point3f(0.0f, 0.0f, -1.0f); // north
    Point3f t = new Point3f(0.0f, 0.721f, 0.0f); // top

    TriangleArray pyramidGeometry = new TriangleArray(18,
            TriangleArray.COORDINATES);
    pyramidGeometry.setCoordinate(0, e);
    pyramidGeometry.setCoordinate(1, t);
    pyramidGeometry.setCoordinate(2, s);

    pyramidGeometry.setCoordinate(3, s);
    pyramidGeometry.setCoordinate(4, t);
    pyramidGeometry.setCoordinate(5, w);

    pyramidGeometry.setCoordinate(6, w);
    pyramidGeometry.setCoordinate(7, t);
    pyramidGeometry.setCoordinate(8, n);

    pyramidGeometry.setCoordinate(9, n);
    pyramidGeometry.setCoordinate(10, t);
    pyramidGeometry.setCoordinate(11, e);

    pyramidGeometry.setCoordinate(12, e);
    pyramidGeometry.setCoordinate(13, s);
    pyramidGeometry.setCoordinate(14, w);

    pyramidGeometry.setCoordinate(15, w);
    pyramidGeometry.setCoordinate(16, n);
    pyramidGeometry.setCoordinate(17, e);
    GeometryInfo geometryInfo = new GeometryInfo(pyramidGeometry);
    NormalGenerator ng = new NormalGenerator();
    ng.generateNormals(geometryInfo);

    GeometryArray result = geometryInfo.getGeometryArray();

    // yellow appearance
    Appearance appearance = new Appearance();
    Color3f color = new Color3f(Color.yellow);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Texture texture = new Texture2D();
    TextureAttributes texAttr = new TextureAttributes();
    texAttr.setTextureMode(TextureAttributes.MODULATE);
    texture.setBoundaryModeS(Texture.WRAP);
    texture.setBoundaryModeT(Texture.WRAP);
    texture.setBoundaryColor(new Color4f(0.0f, 1.0f, 0.0f, 0.0f));
    Material mat = new Material(color, black, color, white, 70f);
    appearance.setTextureAttributes(texAttr);
    appearance.setMaterial(mat);
    appearance.setTexture(texture);
    Shape3D shape = new Shape3D(result, appearance);
    group.addChild(shape);

    // above pyramid
    Vector3f viewTranslation = new Vector3f();
    viewTranslation.z = 3;
    viewTranslation.x = 0f;
    viewTranslation.y = .3f;
    Transform3D viewTransform = new Transform3D();
    viewTransform.setTranslation(viewTranslation);
    Transform3D rotation = new Transform3D();
    rotation.rotX(-Math.PI / 12.0d);
    rotation.mul(viewTransform);
    universe.getViewingPlatform().getViewPlatformTransform().setTransform(
            rotation);
    universe.getViewingPlatform().getViewPlatformTransform().getTransform(
            viewTransform);

    // lights
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
            1000.0);
    Color3f light1Color = new Color3f(.7f, .7f, .7f);
    Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color,   
 light1Direction);
    light1.setInfluencingBounds(bounds);
    group.addChild(light1);
    Color3f ambientColor = new Color3f(.4f, .4f, .4f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    group.addChild(ambientLightNode);

    return group;
  }
}
Alex Byrth
  • 1,328
  • 18
  • 23