Handling Depth?
Handling Depth?
Hello! I am new to both Lua and Love, and I was wondering how you guys manage drawing depth of images/ the 'z' axis? Do you just have a specific drawing order? Ie: Background -> Player -> Overlay? But what if you need to change it around?
Re: Handling Depth?
There's a tutorial on drawing order on the wiki; that might provide some guidance.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Handling Depth?
Well, Löve will draw stuff in the order you call for it.
So the easiest way is just to call everything in the order you want to layer them from back to front.
If you want to get techy, dump all the stuff you want to draw into a table, include a zindex variable, then use a sorting function to reorder the table rows by zindex then run through the table and draw the stuff in that order. With that method you could make pseudo-3d side-scrolling beat-em-up games like the old TMNT and Simpsons arcade games which used this method to make sure a character higher up on the screen (Further back) was drawn first with everything else drawn over it.
So the easiest way is just to call everything in the order you want to layer them from back to front.
If you want to get techy, dump all the stuff you want to draw into a table, include a zindex variable, then use a sorting function to reorder the table rows by zindex then run through the table and draw the stuff in that order. With that method you could make pseudo-3d side-scrolling beat-em-up games like the old TMNT and Simpsons arcade games which used this method to make sure a character higher up on the screen (Further back) was drawn first with everything else drawn over it.
Re: Handling Depth?
Is it not possible to use the OpenGL z depth at all in Love then? I'm currently working on some shaders, and it would be nice to use the z coordinates that are automatically passed to the shaders anyway (which I assume are always sent as zero from Love?), rather than have to send them separately myself. I can think of plenty of cool shader effects that could be based on z-order!
Re: Handling Depth?
You need a depth buffer.
Which means you need to ffi import SDL and import gl functions to create one.
Look at how love3d does it.
Which means you need to ffi import SDL and import gl functions to create one.
Look at how love3d does it.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests