Re: Sphere SFML v0.90
Reply #288 –
Ok, so weird trick, in SphereSFML you can repeat loops like this to maximize performance:
// slower:
function Draw() {
for (blah) {
DrawA();
DrawB();
DrawC();
}
}
// faster:
function Draw() {
for (blah) { DrawA(); }
for (blah) { DrawB(); }
for (blah) { DrawC(); }
}
Sounds counter-intuitive, huh? But it actually draws faster (higher game fps) since the spritebatcher can batch "like" images easier. (A test demo went from 4900 fps to 6100 fps on my machine, almost 25% faster) Now, in most sprite batchers you can tell it to reorder the textures before each commit. This will undoubtedly change the blitting order for each image, so it's something you have to know going into it. This will increase performance by doing the above optimization on a per-texture basis (since in most hardware acceleration, textures changes are often indicators to change state). Trouble is, Sphere was never designed with this in mind so I can't easily incorporate that behavior into Sphere. There is a way for me to rig a 'manual' mode with a BeginBatch() and EndBatch() call, but of course it won't affect earlier games. And even then you'd pass a parameter into BeginBatch() something like BATCH_ORDERTEX_ASC or BATCH_ORDERTEX_DESC.
(Just posting this out of intrigue).
Edit:
A demo, just to show what it means to keep using the 1 for loop approach:
function Draw() {
BeginBatch(BATCH_ORDERTEX_ASC);
for (blah) {
DrawA();
DrawB();
DrawC();
}
EndBatch(); // it is here textures are committed, rather than some place above.
}