3DzzD: Offscreen rendering

I’m trying to get 3DzzD to render without having a visible display - i’ve got the following which almost works, but the actual library doesn’t want to give me any output:


public class DzzdAppTest
{

	public static void main(String[] args)
	{
		Toolkit.getDefaultToolkit();
		
		DzzdAppTest app = new DzzdAppTest();
		app.run();
	}
	
	private JFrame frame;
	private OwnCanvas canvas;
	
	
	IRender3D render3d;
	IScene3D scene3d;
	
	
	
	public DzzdAppTest()
	{
		createDzzd();
		
		frame = new JFrame();
		frame.setLayout(new BorderLayout());
		
		canvas = new OwnCanvas();
		canvas.setMinimumSize( new Dimension(200, 200));
		canvas.setPreferredSize( new Dimension(200, 200));
		canvas.setMaximumSize( new Dimension(200, 200));
		
		frame.getContentPane().add(render3d.getCanvas(), BorderLayout.NORTH);
		frame.getContentPane().add(canvas, BorderLayout.CENTER);
		
		frame.setSize(200, 400);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		render3d.setScreenUpdateEnabled(true);
		render3d.setPixelUpdateEnabled(true);
		render3d.getCanvas().setVisible(true);
		render3d.getCanvas().invalidate();
		
		// This will not render anything
		renderSingleFrame();
		
		frame.pack();
		frame.setVisible(true);
		
		// Now the frame is visible (and the canvas is valid) this will render correctly
		renderSingleFrame();
	}
	
	private void createDzzd()
	{
		// Ask 3DzzD factory for a fresh Scene3D
		this.scene3d = DzzD.newScene3D();	
		
		//Create a Scene3D loader and link it to a 3DS file
		IScene3DLoader loader = DzzD.newScene3DLoader();
		loader.loadScene3D("file:/Users/Orangy/Documents/CodeRepository/Tectonicus/Data/Test/","CUBE.3DS");
		
		// Add the loader to the scene
		this.scene3d.setScene3DLoader(loader);
		
		// Wait until all object & texture are loaded
		while(this.scene3d.getNbMonitoredSceneObject()!=0)
		{
			this.scene3d.updateMonitoredSceneObjects();	
			DzzD.sleep(10);
		}
		
		// Set the active camera in the 3d scene
		this.scene3d.setCurrentCamera3DByName("Camera01");
		
		// Ask 3DzzD factory for a software 3D Render
		this.render3d = DzzD.newRender3D(this.getClass(), "SOFT", null);
		
		// Set the Render3D size and enable maximum antialias
		this.render3d.setSize(200, 200 ,7);
		
		// Set Camera Aspect ratio to 1:1
		this.scene3d.getCurrentCamera3D().setZoomY(((double)this.render3d.getWidth())/((double)this.render3d.getHeight()));	
		
		// Tell the Render3D wich camera it should use to render
		this.render3d.setCamera3D(this.scene3d.getCurrentCamera3D());
	}
	
	public void run()
	{
		Canvas c = new Canvas();
		Graphics g = c.getGraphics();
		System.out.println(g);
	}
	
	public void renderSingleFrame()
	{
		//Set the scene to world space
		this.scene3d.setScene3DObjectToWorld();
		
		//Set the scene to active camera space
		this.scene3d.setScene3DObjectToCamera();
		
		//Tell the 3D render to compute & draw the frame
		this.render3d.renderScene3D(this.scene3d);
	}
	
	private class OwnCanvas extends Canvas
	{
		private static final long serialVersionUID = 1L;

		@Override
		public void paint(Graphics g)
		{
			super.paint(g);
			
			g.setColor(Color.green);
			g.fillRect(0, 0, 200, 200);
			
			render3d.getCanvas().paint(g);
		}
	}
}

I’ve been poking around the source but unfortunately can’t seem to spot anything obvious. Does anyone have any hints as to how to fix this? (Dzzd? You around?)

Thanks.

Actually, this modification seems to fix things:

	public final void drawPixelsOnCanvas(Canvas canvas)
	{
		Graphics g=canvas.getGraphics();
		
		if(this.useMIS)		
			this.imageMemoire.newPixels();

		// pulled this out of the g!=null test
		((Render2D.PCanvas)canvas).image=this.image;						
		
		if(g!=null)
		{
			canvas.update(g);
		}
	}

I never experienced with offlscrren rendering but maybe try this one to disable screen update :

[quote]yourRender.setScreenUpdateEnabled(false);
[/quote]
then you will probably have to add a method in Render3D that return the rendered pixel as an int array and/or the Image object result