Recursive rendering

This isn’t really debugging, and I don’t really need help with it, since I don’t have problem with it so far.

I’m pretty sure that anyone who has done something recursive knows what I’m talking about.

Lets say I have a recursive data structure like json or something where each node holds few other nodes.
If you do it the easy recursive way where you do:


void render() { draw(this); children.render(); }

what ends up happening, is that the first nodes that get rendered, are the ones that are furthest down the node path.

Got any ideas how to correct that? :slight_smile:

Really? I would think it’s the other way around: when every node renders itself first and then calls the sub-nodes, the nodes furthest down are rendered last and those are the ones that you see.

Anyway, to answer your question, switch the places of the draw(this) and children.render() calls will reverse the order of rendering.

WT* how didn’t I think of that?.

EDIT-
Must be my mindset that children go after parents…