gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Wikipedia botches Bresenham

#157838 - TwentySeven - Fri May 30, 2008 10:12 am

(This was split off another topic, btw, for those thinking I have tourettes or something ;))

Keep in mind that wikipedia article completely botches Bresenham

not only is the code incorrect, it misses the entire point, performing a line walk using no divides and integer only.


Try here instead.

http://www.gamedev.net/reference/articles/article767.asp


Last edited by TwentySeven on Sat May 31, 2008 12:16 am; edited 1 time in total

#157839 - kusma - Fri May 30, 2008 10:47 am

I don't quite get how you mean the wikipedia article is wrong, it looks pretty much correct to me.

#157840 - TwentySeven - Fri May 30, 2008 12:34 pm

Wikipedias article, if the code even works (which the comments suggest it doesn't), sort of misses the point.

The two benefits of a *real* bresenham walk are that it can be done without a divide to calculate the delta per step, and it can be done with pure integer math.

The wikipedia article uses both floats and a divide :)

For the same amount of effort you could have just used a proper floating point gradient stepper.

Read the gamedev.net version and spot the difference.

We could move this discussion to a seperate thread or PM? I think a line stepper is what the original poster was asking about, and it was a good answer. I don't particularly want to derail this thread any further.

#169620 - Karatorian - Mon Jul 27, 2009 8:29 am

First of all, Wikipedia is a Wiki, so if you don't like it, change it. If you don't feel up to it yourself, you could settle for tagging it with one or more of the "fix this" type tags (sounds like "needs an expert" to me).

Secondly, the first (psudo)code example is specifically not optimized, so that the reader can understand it more clearly. The later examples are supposed to be optimized, but perhaps it's not as well done as it ought to be. (I only skimmed the code.)