This preview shows page 1. Sign up to view the full content.
Unformatted text preview: y Clip?
Bad idea to rasterize outside of framebuffer
Also, don’t waste time scan converting pixels
The naïve approach to clipping lines:
for each line segment
for each edge of viewport
find intersection point
pick “nearest” point
pick B if anything is left, draw it
if What do we mean by “nearest”?
How can we optimize this? A D
C Trivial Accepts
Big optimization: trivial accept/rejects
How can we quickly determine whether a line segment is
entirely inside the viewport?
A: test both endpoints. Trivial Rejects
How can we know a line is outside viewport?
A: if both endpoints on wrong side of same edge,
can trivially reject line
can Clipping Lines To Viewport
Combining trivial accepts/rejects
• Trivially accept lines with both endpoints inside all edges of the viewport
• Trivially reject lines with both endpoints outside the same edge of the
• Otherwise, reduce to trivial cases by splitting into two segments
by Cohen-Sutherland Line Clipping
Divide viewplane into regions defined by viewport
Assign each region a 4-bit outcode:
1001 1000 1010 0001 0000 0010 0101 0100 0110 Cohen-Sutherland Line Clipping
Assign an outcode to each vertex of line to test
• Bit 1 = sign bit of (ymax – y)
• If both outcodes = 0, trivial accept
– bitwise OR
• bitwise AND vertex outco...
View Full Document
- Fall '13
- Computer Graphics