Skip to main content
gamedev.net
🔒 Locked

line clip algorithm

Started by shermy101 Oct 29, 2005 at 9:37 PM 1 replies 1k views
Original Post
shermy101
shermy101
just wrote a method for line clipping but it is mammoth. :( what i have done is take 2 pairs of points(x,y) lineStart and lineEnd and found what region they are in. there are 8 regions. 1. x < 0 2. x >= screenwidth 3. y < 0 4 y >= screenheight 5. (1) and (3) 6. (2) and (3) 7. (1) and (4) 8. (2) and (4) i then do a switch() on each point and perform clipping as per region. does anyone have a faster method for doing this rather than having 2 massive switch() statements? i am looking for speed too as this is for a software rasterization engine. thanks.
shermy101
shermy101
yeah thats how i implementated it. yet mine seems somewhat cleaner. maybe i should just leave it. just thought there might be some super dooper bit shift or something, or maybe a magic number you && together like in fastroot :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.