void lineclip(int x0,int y0,int x1,int y1,int xwmin,int ywmin,int xwmax,int ywmax) {
outcode code0,code1;
int midx,midy;
code0=calcode(x0,y0,xwmin,ywmin,xwmax,ywmax);
code1=calcode(x1,y1,xwmin,ywmin,xwmax,ywmax);
if( !(code0 | code1) ) { /*The two points are completely inside the window*/
line(x0,y0,x1,y1);
return;
}
else if(code0 & code1) /*The two points are completely outside the window.*/
return ;
midx=(x0+x1)/2;
midy=(y0+y1)/2;
lineclip(midx,midy,x1,y1,xwmin,ywmin,xwmax,ywmax);
lineclip(x0,y0,midx,midy,xwmin,ywmin,xwmax,ywmax);
}
The calcode routine generates the "code" (same as in Cohen Sutherland algorithm) for the point, which is passed as an argument, against the clipping window boundaries. Unfortunately when I run this routine I get segmentation faults. Can anyone tell me why?
I couldn't find much documentation about this algorithm either in texts or on the net. Any help will be appreciated.
Thanks












