I was
wondering if you found any problem like excessive repaint time, per chance? I
have not compared your
version yet with the one I have tried but mine would have a wierd repaint
issue...when, for example, I moved the
windows off the screen and then moved it back (canvas3d with Swing
panel), the Swing window would take a few
seconds to repaint before any of the buttons were available for
clicking...I don't know if this is a problem with
Swing
per se but I did notice that when trying this on another computer with linux and
the old java 3d the repaint
was
not noticeable....so I can't tell what is going on with that. I'll try to
check my code again and compare
it to
your method and see what happens though...thanks for including the
code.
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".