forums

TNT Basic Forums > Bugs!
Interesting (and very annoying) glitch!
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-09-2005 00:43

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Hi all, here's a good on for you...

I uploaded a sample demonstrating Bresenham's midpoint line algorithm to the directory, and said in the comments that there was a bug with the code which caused it to 'swerve', ie not do what it was supposed to...
Well I've spent weeks trawling through this code to find the bug... Now, at 1:35 in the morning and really needing sleep I ran it in 'hardware' mode. Guess what? No bug! The bug is not in the damn code that I've spent the last two weeks debugging!
So apart from being eternally miffed, I thought I'd better let you know. Run the example in hardware mode and it works fine, though 8 times slower!! And I'm only drawing a 6 pix diameter oval, in white, on a black background.........

Do you know how really, really, REALLY p****d off I am right now?

Thought I'd share that, sorry! Well, sort of sorry. When I calm down I'll be sorry.

Danny (nods) <---not a happy bunny

11-09-2005 07:22

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Morning!

OK, cooled down. Here's the beef, the example draws a line from on point to another, one pixel at a time. When run in software mode the line 'bends', the start of the line sets out on an axially aligned vector (either orthogonally or diagonally dependant on the directional octant), then, after several itterations reverts to the anti-aliased Bresenham line. Though for reasons I still don't understand it manages to hit the end point (or at least reports that it has).

Add the word 'hardware' and the thing runs with no glitch. How the hell is this possible? Algorithm is totally unchanged, just added one word. Can software mode really be drawing pixels in the wrong place?

Well there's one for you Mark! Let me know what you think... Have fun, I did!

Danny (nods)

11-09-2005 23:02

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

for me both modes seem to work the same

what was misbehaving in software mode?? you spent a lot of time saying it didn't work but i couldn't read what exactly went wrong (or maybe i just didn't read enough!)

11-09-2005 23:04

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

ok it 'swerved' (when can we edit forum posts?) for me everything went ok even in software mode

11-10-2005 07:34

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Try this...

Hi Mathew, try setting bSpeed to 1 and changing it slightly so that instead of drawing and erasing an oval, it just plots a point, giving you continuous lines...
Oohhh... Swervy! 8)

Danny (nods)

01-29-2006 03:53

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

I've just tried this and I get the swerve in both hardware and software mode. It's harder to see in hw mode due to the lower framerate affecting the fluidity of the animation, but if you use 'set pixel colour' instead of 'draw oval' you can clearly see the kink in both hardware and software mode.

It's most likely an integer accuracy problem or a bug in the algorithm, if TB was drawing points in the wrong place it would affect more than just the first few pixels of the line.

Sorry!

Mark

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.