There are many aspects of game development that are a trade-off of some sort.
It’d probably pay to test this yourself, and weight up the benefits. Composing text into a batch is CPU work. Compose too much at once, and it may become a CPU performance issue, directly impacting framerate.
So on one hand you have a reduction of GPU calls with batching.
On the other hand you have increased CPU overhead.
Weigh it up in the context of your game, and see what’s going to work for you.
I would also note, that because this is a mature framework, some of the notes you find in the code may be less of an issue now, than they were in the past. CPU’s are a lot more powerful now than they were 9 years ago when that comment was added to the Starling codebase. You’re also working with Starling for OpenFL, not AS3 (which that comment was written under).
When I test this, I’m getting a little over 16,000 characters per draw call. The below code renders 1,612 characters per TextField, and I create 100 text fields (161,200 characters total). The result is 10 draw calls.
class StarlingRoot extends Sprite {
public function new() {
super();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(e:Event):Void {
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
var tex:Texture = Texture.fromBitmapData(Assets.getBitmapData("img/RobotoCondensed.png"), false);
var font:BitmapFont = new BitmapFont(tex, Xml.parse(Assets.getText("xml/RobotoCondensed.xml")));
var fontName:String = font.name != null ? font.name : "RobotoCondensed";
TextField.registerCompositor(font, fontName);
var textFormat:TextFormat = new TextFormat(fontName, 38, 0xFFFFFF);
for (i in 0...100) {
var textField:TextField = new TextField(stage.stageWidth, stage.stageHeight, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
", textFormat);
textField.batchable = true;
textField.pixelSnapping = true;
addChild(textField);
}
}
}
openfl test html5







