Hi again,

You should not need to override the paint method if you
use java instead of javaw as the Java application launcher.

The 'extra' code put there is the:
Toolkit.getDefaultToolkit().sync();
and this was a workaround found by Scott Rutledge for
the following bug:

(http://developer.java.sun.com/developer/bugParade/bugs/4374079.html)

In my test I found that this code also solved some repaint problems I had in the postSwap method, if this is because of the same bug or due to something else I don't know. And currently I have alot to do at work, so I don't feel I have the time to try to find out if it's the same bug or a new one.

To answer the performance question:

I'm developing a CAD like software and it's still to early to try to measure the speed of the scene graph, since much of the time is spent in other parts of the program. But I have not seen any noticeable slowdown when drawing simple shapes in the postswap method.

I started off with trying to use the overlay code found at j3d.org. And if that is faster or slower I don't know, but since I wan't to have parallel projection that code did not work very well.

Hope this answer some of your questions.

Best Regards,

Roger Berggren

ZACZEK, MARIUSZ P. (JSC-DM) (NASA) wrote:
Another question, Roger...

  I noticed you refer to 'javaw' ... would still need to override paint
when
using 'java' ?

  Basically, do you get similar performace when using java as opposed to
javaw?

  I'm going to try your version of the code when I get some
time...comparing
it to my code
 I can see some differences which maybe I can fix and test.

   Mario

P.S. Alejandro Allievi [[EMAIL PROTECTED]] ... I tried to email you back but
I
got my email bounced back  :)

Mariusz Zaczek
NASA - Johnson Space Center
Automated Vehicles and Orbit Analysis / DM35
Flight Design and Dynamics Division
Mission Operations Directorate
Bldg: 30A     Room: 3048B

Disclaimer: "The opinions, observations and comments expressed in my email
                   are strictly my own and do not necessarily reflect those
of NASA."


-----Original Message-----
From: Roger Berggren [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 12:48 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Overlay using Canvas3D.getGraphics, sucess story


Hi,

I know this is an old thread, but I just thought I would share
my successful implementation of overlays using getGraphics.

When using the code below, overriding repaint, I cannot
see any noticeable flickering on my machine. I guess if
the drawing takes to long, the scene might start flickering,
but for simpler overlays this code seems to work very well.

public class OverlayCanvas extends Canvas3D
{
  public OverlayCanvas(GraphicsConfiguration configuration)
  {
    super(configuration);
  }

  public void postSwap()
  {
      Graphics2D g = (Graphics2D) getGraphics();

      g.setColor(Color.red);
      g.setStroke(dashed2);
      g.drawRect(xStart, yStart, width, height);

      // This call is made to compensate for the javaw
      // repaint bug, ...
      Toolkit.getDefaultToolkit().sync();
    }
  }

  // Overriding repaint makes the worst flickering dissapear
  public void repaint()
  {
    Graphics2D g = (Graphics2D) getGraphics();
    paint(g);
  }

  // Paint is also overridden to compensate for the
  // javaw repaint bug
  public void paint(Graphics g)
  {
    super.paint(g);
    Toolkit.getDefaultToolkit().sync();
  }
}

Best regards,

Roger Berggren


Doug Twilleager wrote:




In other words... what, if any, drawbacks now exist to implementing



overlays



in 2d rather than in 3d?







If by 2D, you mean standard Java 2D rendering commands, the biggest

drawback is synchonization.  Java 2D will always render into the front

buffer, and it may not flush its rendering after every request.  The end

result is some very ugly flickering.  The right solution is for the 2D

API's to learn about the back buffer.  Unfortunately, that is a very

painful thing to do across all the platforms we support.



Doug Twilleager

Java 3D Team

Sun Microsystems



===========================================================================

To unsubscribe, send email to  [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  and include in the body

of the message "signoff JAVA3D-INTEREST".  For general help, send email to

[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>  and include in the
body of the message "help".







 - att-1.htm

Reply via email to