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);
}
}