Ok, after reading this interesting post , i tried to implement. Alas it doesn’t save the whole scene. It saves hum… i don’t even know, just compare yourself:
This is one of the screenshots serie:
After removing the alpha channel with ImageMagick, i get the colors (?!!)
convert -alpha off screenshot.png screenshot_without_alpha.png
And here is what i should get (captured while running, with xwd
)
Here is the code:
- in init() , i initialize the texture and its depth buffer:
private var screenshotTexture:h3d.mat.Texture;
private var counter:Int = 1000;
override function init()
{
screenshotTexture = new h3d.mat.Texture(512, 512, [h3d.mat.Data.TextureFlags.Target]);
screenshotTexture.depthBuffer = new h3d.mat.DepthBuffer(screenshotTexture.width, screenshotTexture.height);
(…)
}
- the renderer function is overriden, and the original one is called twice: one for the texture, two for the show (three for the money let’s go let’s go!)
override function render(e:h3d.Engine)
{
screenshotTexture.clear(0);
engine.pushTarget(screenshotTexture);
super.render(e);
engine.popTarget();
super.render(e);
var pixels = screenshotTexture.capturePixels();
hxd.File.saveBytes("screenshot"+ counter + ".png", pixels.toPNG());
counter=counter+1;
}
Thank you for reading