Bad idea to rasterize outside of framebuffer bad

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: y Clip? Bad idea to rasterize outside of framebuffer Bad bounds Also, don’t waste time scan converting pixels outside window outside Clipping The naïve approach to clipping lines: for each line segment for each edge of viewport for find intersection point find 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 Big How can we quickly determine whether a line segment is How entirely inside the viewport? entirely 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, A: same 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 accept inside • Trivially reject lines with both endpoints outside the same edge of the Trivially viewport viewport • Otherwise, reduce to trivial cases by splitting into two segments by Cohen-Sutherland Line Clipping Divide viewplane into regions defined by viewport Divide viewplane viewport edges edges Assign each region a 4-bit outcode: Assign 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 OR • bitwise AND vertex outco...
View Full Document

Ask a homework question - tutors are online