Trouble drawing point-sampled polygons

imagician andru at electron.lcs.mit.edu
Sat Feb 9 09:41:37 AEST 1991


In article <1991Feb8.200816.20381 at Neon.Stanford.EDU> loan at Neon.Stanford.EDU (James P. Loan) writes:
>
>I'm trying to draw several copies of the same polygon and I'm having
>a hard time getting them to look EXACTLY alike. I realize that there
>is round-off error when translating within a window, but the manual
>presents a way to fix that. I thought the purpose of the +/-0.5
>adjustment in an ortho2() call was to "move" the coordinate system
>so that integer vertices would fall exactly in the center of pixels.
[...]
>not points on the lines connecting the vertices.
>	    viewport(0,(Screencoord)xs-1,0,(Screencoord)ys-1);
>	    ortho2(-0.5,(Coord)xs+0.5,-0.5,(Coord)ys+0.5);
>/*	    ortho2(0.0,(Coord)xs+1,0.0,(Coord)ys+1); */


    Your ortho calls are wrong. The viewport is xs pixels wide, but
    you are mapping a coordinate system which is (xs+1) wide onto it.
    What you want is

	ortho2(-0.5, (Coord)xs-0.5, -0.5, (Coord)ys-0.5);

    Any apparent discrepancy is because viewport() takes pixel
    indices as arguments, whereas ortho() calls take coordinates
    as arguments.

Andrew



More information about the Comp.sys.sgi mailing list