Skip to main content

Canvas3D update( ) control, and repaint( ) flickering

4 replies [Last post]
jarodrussell
Offline
Joined: 2010-05-19
Points: 0

Two questions at once:

1. I have a MouseListener attached to the Canvas3D, and every time a mouse event happens I want to update the canvas. But it flickers extremely. What's the problem, and how can I avoid it?

2. And is there a way to fully control the update or repaint operations of the Canvas3D? At the moment it seems to update itself at will. But I regularly have to perform some huge scene changes and I don't want it to repaint until the changes are completely done. Right now, the scene elements that are not changed are perfectly fine, but the elements that are changed begin to flicker. Probably beause I have to detach and reattach BranchGroups, and the canvas probably also repaints while these BranchGroups are detached. I want to avoid that.

Thanks in advance,
Jarod

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jarodrussell
Offline
Joined: 2010-05-19
Points: 0

I have a behavior now that starts picking on WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED). Whatever is picked shall be displayed on the Canvas using the postRender() method. But nothing happens. How can I force the canvas to update at the end of the processStimulus() method of my Behavior?

Every time I call either:

canvas.update(canvas.getGraphics());
canvas.paint(canvas.getGraphics());
canvas.repaint();

the canvas flickers HEAVILY.

aces
Offline
Joined: 2003-07-17
Points: 0

You shouldn't call Canvas3D methods related to 2D drawing, as redraw, repaint etc. If you try to use those methods, flicker will happens.
Canvas3D "repaint" is automatic, you can only limit max frame rate.

For 2D drawing on top of 3D, try the following:

use JCanvas3D - other colegues my guide you better, on this -

or subclass Canvas3D, more or less like below :

[code]

MyCanvas3D extends Canvas3D {

public void postRender(){
J3DGraphics2D g2 = canvas3d.getGraphics2D();

// performs drawings using g2, which is a subclass of Graphics2D
// check canvas size to correctly position

// flush
g2.flush();
}

}
[/code]

jarodrussell
Offline
Joined: 2010-05-19
Points: 0

I now have build the functionality in the processStimulus(...) method of a Behavior. The changed objects are now displayed smooth and flicker free on the canvas.

[b]BUT[/b] I also have a HUD display (with the postRender() method of the canvas),
displaying information about the geometry (and moving with it) and that still flickers when the geometry is changed, moved, etc... .

How can I synchronize the postRender() method so that it's as smooth and flicker-free and the rest?

Philip Whitehouse

You should probably be double-buffering if you aren't already. This sounds like the route of your problems.

Philip Whitehouse

On 4 Sep 2010, at 19:04, java3d-interest@javadesktop.org wrote:

> I now have build the functionality in the processStimulus(...) method of a Behavior. The changed objects are now displayed smooth and flicker free on the canvas.
>
> [b]BUT[/b] I also have a HUD display (with the postRender() method of the canvas),
> displaying information about the geometry (and moving with it) and that still flickers when the geometry is changed, moved, etc... .
>
> How can I synchronize the postRender() method so that it's as smooth and flicker-free and the rest?
> [Message sent by forum member 'jarodrussell']
>
> http://forums.java.net/jive/thread.jspa?messageID=481888
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
> For additional commands, e-mail: interest-help@java3d.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net