## Determining whether a polygon face is front-facing or back-facing.

### Determining whether a polygon face is front-facing or back-facing.

I asked my students to write a note on how OpenGL determines whether
front- and back-facing. Essentially, Iwas inviting them to elaborate
on the following from my notes -- in turn copied from the Red Book:

"
Front- or back-facing depends on the sign of the polygon's area
computed in window coordinates. We can compute this area as:

a = \frac{1}{2} \sum_{i=0}^{n-1} x_i y_{i \oplus 1} - x_{i \oplus 1}
y_{i},

where $i \oplus 1 = (i+1) \mod n$ and where $x_i$ and $y_i$ are the
\emph{window} coordinates of the $i$th vertex of the $n$ vertex
polygon. $i \oplus 1 = (i+1) \mod n$ simply wraps around back to zero
at $i=n$, i.e. there is no $i=n$, so we go back to the first (zeroth
index) point.

If \verb|GL_CCW| has been specified, if $a>0$, the polygon is
considered to be front-facing; otherwise, it is back-facing.
"

Mostly, they gave answers based on the sign of the scalar product of
the viewing point and the normal to the face. Which seems reasonable;
unless OpenGL actually uses the former, and the former is easier to
compute.

Any suggestions?

TIA,

Jon C.

### Determining whether a polygon face is front-facing or back-facing.

Since OpenGL can't draw non-planar polygons, it amounts to the same result
but since a normal is easier to compute...
All planar convex polygons get tessellated. OpenGL doesn't do non-planar or
concave poygons, so the formulation is overkill.

Note that it is *computed* face normal, NOT the normal(s) you supply for
lighting.

jbw