3 ms·
Fast and branchless line drawing routines
- NateLawson 14y agoThis is an interesting advance from a few years back in 2D line drawing routines. With 3D being all the rage, we sometimes forget that some environments still need fast 2D code that even works on old 8-bit CPUs. The classic routine was by Bresenham. The previously fastest routine was by Wu, but his approach is complex. Compare them and see why: http://www.edepot.com/linebresenham.html http://www.edepot.com/linebresenham.html http://www.edepot.com/linewu.html http://www.edepot.com/linewu.html By comparison, EFLA just uses a pair of increment values in its main loop and no branching. I don't want to spoil how it works, but the key is in how the x and y increment values are chosen and why one of them is taken from the upper 16 bits.