flixel-addons
flixel-addons copied to clipboard
FlxScreenGrab doesn't match PrintScreen results
In a customized version of crashdumper, I dump a screenshot on crash, using FlxScreenGrab.
Here's FlxScreenGrab's output:
Here's the system's native PrintScreen:
The FlxScreenGrab image's tileset has little artifacts in it -- perhaps because I'm using the "tileset smear trick" where you add borders to each tile to avoid cross-tile bleed. Also note that the flixel-ui elements are arbitrarily offset from the native screenshot.
FlxScreenGrab just looks like it does a naked draw dump from the stage, so how is this discrepancy even happening? It should be using the same draw logic as everything else, right?
I think OpenFL might be to blame for these inaccuracies. I've noticed the same with draw()ing the content of a FlxCamera into a BitmapData.
Ah, so the problem is that draw() is basically saying "render the stage's components" or something? It's not a straight pixel-dump?
Is there any way to just grab the last set of pixels blitted to the screen?
I talked to Joshua in the OpenFL slack:
-
draw()
uses software instead of hardware rendering, so that's where the discrepancies might be coming from - in this particular case, there seem to floating point rounding errors (if you compare the two images, everything seems to be always one pixel or so off)
- it might be possible to make a screenshot via OpenGL at low-level as a workaround (
openfl.gl.GL.readPixels()
/ related forum thread)
GL.readPixels() causes all sorts of crashing. I'm not sure how to use that :(