pixel icon indicating copy to clipboard operation
pixel copied to clipboard

Specifying Z-order

Open PlainSight opened this issue 8 years ago • 6 comments
trafficstars

Currently as far as I can tell there is no way of specifying the z-order of what you are drawing. This requires ordering everything you are rendering before making draw calls (painters algorithm).

Is providing some way to specify the z-order of objects something which would be considered or is this out of scope?

PlainSight avatar Jun 12 '17 23:06 PlainSight

Hi!

Z-order is totally not out of scope and it's been bugging me for some time. I certainly want to support it somehow. We're currently working on a little semi-internal redesign (not affecting any high-level API, just some lower-level stuff) in order to better support implementing arbitrary effects. One of these effects could probably implement Z-order, we'll see.

Conclusion is, I want this to be implemented, but I need to figure out a few things first.

I'll keep this issue open, until this is implemented.

faiface avatar Jun 13 '17 09:06 faiface

That's great to hear, thanks for the response.

PlainSight avatar Jun 13 '17 21:06 PlainSight

I used to work on my own game engine called turboOcto which got scrapped and replaced by pixel. I used a sorted set which integrated nicely with the rest of the engine but might be a bit more difficult to integrate into pixel. But generally the idea was: each time a sprite is created, keep a reference to that sprite in a sorted list. However keeping the list sorted requires quite some computing power when doing operations other than reading the list. See for yourself and take what you need: https://gitlab.com/Pixdigit/sorted (Also turboOcto can do animated sprites so in case thats interesting feel free to copy. There would need to be some adjustments as turboOcto's sprites are always in VRam)

Pixdigit avatar Jan 09 '19 21:01 Pixdigit

@Pixdigit What are the advantages of using your Set over the builtin list: https://golang.org/pkg/container/list/ (as tone cannot always be clear in written text: this is a genuine question, not a loaded one!)

bcvery1 avatar Feb 26 '19 12:02 bcvery1

For once a Set can not have duplicate entries. But my implementation uses an array list instead of an doubly linked list. So in specific situations it may be somewhat more performant. But come to think of it, when inserting the array has to be extended which is in itself quite expensive. So my guess would be that apart from appending the dl list might actually be faster if you intent to only iterate over the list and not do anything else with it.

Pixdigit avatar Feb 27 '19 22:02 Pixdigit

@Pixdigit thank you for the insight :)

bcvery1 avatar Feb 28 '19 08:02 bcvery1