Trouble drawing point-sampled polygons

Andrew Myers andru at electron.lcs.mit.edu
Tue Feb 12 12:24:27 AEST 1991


In article <84845 at sgi.sgi.com> garyt at westcoast.esd.sgi.com (Gary Tarolli) writes:
>When you are drawing old style polygons, you want your polygon vertices to 
>land exactly on pixel centers.  But when you are drawing point-sampled
>polygons you want the opposite - you should place your vertices exactly
>on the pixel borders.  This is because the decision to fill a pixel or not
>is based on whether the pixel center is in/outside  of the polygon. If
>the polygon edge goes right thru the center of a pixel, then you are
>susceptable to round off error. If you move your vertices to pixel
>borders (1.5, 2.5, etc) then it takes a big roundoff error to make
>things fail ( magnitude of .5).

This is of course correct. Drawing lines & points is sort of antithetical
to drawing new-style point-sampled polygons. You can think of lines, points
and old-style polygons as new-style polygons which have been bloated by
0.5 pixels. This can cause problems in some programs.

In the case of the program which was presented, I believe the problem
was simply a bad ortho2() call, as I stated in an earlier article.

If you want to draw true point-sampled polygons, you should note that
it is only supported on the PI and the VGX. The GT supports new-style
polygons but does not do point-sampling.  You should set your
ortho2 call to either (0,xs,0,ys) or (-0.5, xs-0.5, -0.5, ys-0.5) depending
on whether you are in new-style polygon mode or old-style, respectively.
Old-style is the default mode, last time I checked.

If you want to use new-style polygons and have your lines work well,
then you should ensure that the line goes down the center of the pixel.
This can be done by either using coordinates with a .5 adjustment, or
by a translate(0.5,0.5,0.0) call followed by an opposing translate()
when you are finished drawing lines and points.

I recommend using new-style polygons. And if you are doing user interface
work, use the sbox() calls whenever possible.

Andrew



More information about the Comp.sys.sgi mailing list