Page 1 of 1
Best method to implement 9 slice?
Posted: Fri Sep 20, 2019 3:44 am
by ShoesForClues
I'm currently working on a GUI framework and I'm trying to implement 9 slice in order to properly scale windows and borders. What's the best way to go around this? I'm aware that you could use quads to only draw certain parts of an image, but is that more efficient than just using setScissor?
Re: Best method to implement 9 slice?
Posted: Fri Sep 20, 2019 6:26 am
by Nelvin
It's more efficient as changing the scissorrect will stop batching, so you'll create 9 draw calls. Also using scissors will be more complicated to implement as scissors are in screen coordinates, i.e. pixels, so you'd have to do more transformation work on your coordinates (in case you use any scaling while drawing but given the huge difference of monitor resolutions this is highly expected).
Also, if a 9 slice doesn't change often, you may add all the 9 quads manually into a spritebatch and only change it if you required (or create a mesh).
Re: Best method to implement 9 slice?
Posted: Fri Sep 20, 2019 6:51 pm
by CrimsonGuy
Re: Best method to implement 9 slice?
Posted: Thu Oct 24, 2019 12:23 am
by elneiew
Finally a good explanation of what that enumtype does.
I’ve been waiting a long time to know how it works.
(Has no information on the wiki, except the tiny bit I added, which lacks about everything related to this)