opengl – LibGDX Desk rendering order draw calls

opengl – LibGDX Desk rendering order draw calls

[ad_1]

I am utilizing LibGDX Desk for drawing some easy construction however I’m having drawback with draw calls and texture binding dealing with.

For clarification, I’ve a TextureAtlas loaded and I can get the next textures from it. After which I’ve a Desk with following construction:

desk.add(new Picture(textureAtlas.findRegion("region1")))
desk.row()
desk.add(new Picture(textureAtlas.findRegion("region2")))
desk.row()
desk.add(new Picture(textureAtlas.findRegion("region3")))

On this case, it renders the desk with just one draw name and one texture binding, as all the feel areas belongs to the identical loaded Texture.

However now, if I create a desk interleaving with one other Actor, like this:

desk.add(<some actor>)
desk.add(new Picture(textureAtlas.findRegion("region1")))
desk.row()
desk.add(<some one other actor>)
desk.add(new Picture(textureAtlas.findRegion("region2")))
desk.row()
desk.add(<some one other actor>)
desk.add(new Picture(textureAtlas.findRegion("region3")))

The feel areas will not be drawn in sequence as earlier than, it’s a necessity a brand new draw name / texture binding for every one of many three texture areas from textureAtlas.

I quick, if I draw the three texture areas in sequence, one after the opposite, it makes use of just one draw name and texture binding. In any other case, if there’s something else within the center, it makes use of a brand new draw name and texture binding for every texture area, even when they’re a part of the identical texture.

My query is, is there any approach I can re-arrange the Desk’s drawing order, so I draw the feel areas one after the one other, and solely after I draw the one other Actors? Even when my desk has the visible construction I offered above? Or do I must create a customized Desk class for dealing with this correctly?

One factor I’ve already tried was to make use of desk.getChildren(). This returns a listing of the desk’s youngsters Actors. And I attempted to attract the weather from this checklist within the order I need, however they aren’t positioned appropriately (all the time at place (0,0)). I additionally tried to recreate this youngsters checklist with the order I need, however I can not do desk.setChildren().

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply