Skip to main content

About getting some control to render 2D graphics

1 reply [Last post]
Joined: 2008-03-15

Hi guys,

I'm really a newbie to Java3D. My current application needed me to render some 2D images and graphics on the screen, while also manipulate a 3D object. Therefore, I actually would like (if this is possible :)) that the Java3D engine to stop rendering when I was doing all the 2D stuff, and get back to work when I manipulate 3D geometry.

I was reading about the rendering modes and extending the Canvas3D class, but I got somewhat lost. Could anybody gave me a guide or hint?

Thanks a lot!!


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-07-17

I assume you already know Java2D, along side Java3D :D

Check Javadocs about J3DGraphics2D , Canvas3D and mixed rendering mode.

Basically, J3DGraphics2D is a Graphics2D subclass, and will be used for 2D rendering on top of 3D graphics.

Extends a Cavas3D and on override postRender() method. In this method, get a J3DGraphics2D instance and draw it in your screen.

public class MyCanvas3D extends Canvas3D{

// override constructors

public void postRender(){

J3DGraphics2D g2 = this.getGraphics2D();

// do the drawing



I don't know what works best, if using 2D on overrided postSwap() or postRender(), perhaps someone else can give some tips. Same thing about flush(true) or flush(false).

Anyway, I hope it helps.