Problem with drawTiles + draw on cpp target

Hi !

First of all, please excuse my broken english.

I test Haxe since years, in my free time, and I enjoyed the last released of Haxe / OpenFL when…

For manage a layer system, I want to draw on many sprites with “drawTiles”, then addchild those on a “root” container (not on displayList), and finally draw this container on a bitmap which is on stage.

Example :

var wrapper:Sprite = new Sprite();

var img:BitmapData = Assets.getBitmapData("img/spritesheet.png");
var t:Tilesheet = new Tilesheet(img);
t.addTileRect(new Rectangle(64, 64, 64, 64));

t.drawTiles(wrapper.graphics, [0, 0, 0], false);

var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0);
var canvas:Bitmap = new Bitmap(bmd);

addChild(canvas);
bmd.draw(wrapper);

It works on flash target, but not with cpp : the bitmap “canvas” show a portion of spritesheet, but from the origin of the spritesheet (not at 64, 64).

If I skip the bmd.draw and just addchild the wrapper on stage, the result is good.

var wrapper:Sprite = new Sprite();

var img:BitmapData = Assets.getBitmapData("img/spritesheet.png");
var t:Tilesheet = new Tilesheet(img);
t.addTileRect(new Rectangle(64, 64, 64, 64));

t.drawTiles(wrapper.graphics, [0, 0, 0], false);

addChild(wrapper);

I don’t understand :pensive:

https://github.com/Grouuu/demoOpenFLbug

openfl 3.4.0
lime 2.7.0
hxcpp 3.2.193

Hi!

I think you hit an edge case where our Cairo (software) renderer is not running drawTiles as it should :frowning:

If you want performance, don’t use bitmapData.draw – this turns a GL hardware render process into a software process :smile:

However, we should try to resolve this. Thank you for the bug report!

1 Like

No problem, I’ll use just drawTiles so.

Thank you ! :slight_smile: