Also,
is there a difference depending on what java you use...1.3 versus
1.4?
Mario
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-----Hi,
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
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 implementingoverlaysin 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".