In OpenGL (ES for Android if it matters), is using GL10.glTranslatef(x, y, z); then drawing an object (in my case a hexagon tile) more efficient / practical than passing the new coordinates to the object and refactoring the buffers (if need be)?
In OpenGL (ES for Android if it matters), is using GL10.glTranslatef(x, y, z); then
Share
That depends on the rest of your code. It’s likely to be a negligible difference if you’re talking about the difference for a single quad, for example. The golden rule is to avoid state changes and to optimise geometry around that aim. If you have, say, 10000 tiles that you can draw in a single call to
glDrawElementsorglDrawArraysif you translate in your code and upload vertex locations en masse then it’s as certain as it can be that you’ll see an improvement. If you’re doing one call toglDrawElementsorglDrawArraysper tile then you’re unlikely to notice any difference either way.So: it’s a worthwhile change if it allows you to batch more geometry together, otherwise it’s probably not going to make much odds. From my anecdotal experience, on a first generation iOS device, which had a PowerVR MBX, with a sprite-style engine, I went from the device struggling a little with a few hundred sprites to it being able to handle thousands. Batching my geometry meant that GPU/CPU synchronisation was no longer the bottleneck.