How to draw the outline of a selected mesh the way Blender does it?

here’s a good thread with more iptions: