Welcome
Welcome to a320

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

How to draw lines?

Any and all A320 homebrew topics

Moderator: Moderators

Re: How to draw lines?

Postby flatmush on Tue May 19, 2009 11:04 pm

My code uses the DDA algorithm, because that is the algorithm I use for drawing triangles and using two different algorithms would cause graphical glitches.
It uses rounded fixed point maths for one of the iterating values to ensure accuracy, and to ensure that polygons line up.

It has special cases for horizontal lines, because horizontal lines can be drawn two pixels at a time in good conditions and for vertical lines because they are common so a special case is faster.

All the other algorithms try to use pointer arithmetic wherever possible to remove multiplies, there is still a multiply in the function for drawing shallow lines which I intend to remove.

The main optimization is clipping
- If lines are completely outside the screen then they aren't drawn (best case).
- If lines potentially intersect the screen then it will draw them with clipping (worst case).
- If lines are completely within the scene then it will draw them without clipping (common case).
C99 samples without using s2dsdk | MineSweeper | AstroLander
For help with dingoo programming or just in general, join our IRC at irc://irc.freenode.net/#dingoo-a320
flatmush
 
Posts: 30
Joined: Thu May 14, 2009 1:29 pm
Location: Manchester, UK

Previous

Return to Homebrew

Who is online

Users browsing this forum: nine10 and 2 guests