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] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

  

Reply via email to