1) x += i * xinc;
this is a float multiplication rounded to an integer. It doesn't guarantee you to go through all integers from you starting x
to your final x
. This means your line may have holes in it...
2) Your Bresenham implementation is wrong. You do not add steps to x
. You increment x
on every iteration and add delta_y
to an error counter. When the error counter is larger than delta_x
you increment y
and substract delta_x
from the error counter.
This is the explanation for a line whose delta_y
is greater than 0 and inferior to delta_x
. Do the rotation for all other cases.
3) For efficiency: this is a bit tricky. Oldest computers could not do floating point computation easily. Up until the Pentium it was common to not have any x87 coprocessor and all floating point computation was done in software. This was 1000s times slower than doing simple integer arithmetic. Nowadays all computers can do SIMD operations (i.e. they use floating-point vector extensions); it may not be the case any more.