Login  Register

Re: Mac Canvas3D location bug

Posted by Manu on Oct 06, 2013; 12:53pm
URL: https://forum.jogamp.org/Mac-Canvas3D-location-bug-tp4030052p4030165.html

Thanks Sven, we're very close to a working solution. Canvas3DVisibilityTest and Canvas3DPositionInDialogTest works perfectly on my side now.
Miserably, I noticed an other visibility issue that needs to be resolved for my use case. The canvas 3D should disappear when one of its parent is/becomes invisible too, something that may happen when you have to combine different panels/layouts in a window. Here's a simple test showing this issue:
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.SimpleUniverse;

public class Canvas3DAncestorVisibilityTest {
  public static void main(String [] args) {
    // Create a new canvas 3D bound to a universe
    GraphicsConfigTemplate3D gc = new GraphicsConfigTemplate3D();
    Canvas3D canvas = new Canvas3D(GraphicsEnvironment.getLocalGraphicsEnvironment().
        getDefaultScreenDevice().getBestConfiguration(gc));
    new SimpleUniverse(canvas);
    // Put it in a panel
    final Panel panel = new Panel(new GridLayout(1, 1));
    panel.add(canvas);

    // Create a check box that hides / shows canvas panel
    final Checkbox checkbox = new Checkbox("Visible canvas", true);
    checkbox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ev) {
        panel.setVisible(checkbox.getState());
        System.out.println(panel.isVisible());
      }
    });

    // Build a GUI that displays canvas panel and check box
    Frame frame = new Frame("Canvas3DAncestorVisibilityTest");
    frame.setLayout(new BorderLayout());
    frame.add(panel, BorderLayout.CENTER);
    frame.add(checkbox, BorderLayout.NORTH);
    frame.setSize(200, 200);
    frame.setVisible(true);
  }
}

By the way, is there a simple way to measure the frame rate with Java 3D or JOGL?
Emmanuel Puybaret