Welcome, Guest. Please login or register.

Author Topic: Triangle fill algorithm, solved!  (Read 3120 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Triangle fill algorithm, solved!
« on: February 15, 2007, 11:26:44 AM »
Fixed before I even got a chance to read it and find out what was wrong :-D

Without the extend operation, your sign will definately get trashed, since all you end up with is the same pattern of bits in the least significant half of your target register, turning a negative 16-bit 2's complement word value like -1 into the positive longword value 65535.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Triangle fill algorithm, solved!
« Reply #1 on: February 15, 2007, 12:23:03 PM »
Incidentally, there are versions of the DDA line drawing algorithm you can use to determine the start and end points of each horizontal rasterline fragment of your triangle. The fastest of these algorithms don't use any multiplication or division at all.
int p; // A