[CSC 315] OpenGL's Little Secret

Andrew Pounds pounds_aj at mercer.edu
Sat Oct 16 13:27:30 EDT 2010


By now most of you have figured out that GL will not fill concave 
polygons (if you have no idea what I am talkin about, then you should 
probably review the section in the OpenGL programming guide -- starts 
around page 40 in the 7th edition).

I am encouraging you all to go ahead and get the project done using a 
"wireframe" polygon that you draw with GL_LINE_LOOP.  Once you get 
everything working, then you can jump back to try and filling the 
polygon.  Here's why I recommend this plan of action.

   1. To fill concave polygons in OpenGL you have to tesselate them
      (which means you effectively have to convert the polygon area into
      a series of triangles -- each of which has to be filled
      individually).  While OpenGL offers this ability in the GLU
      library, it is a bit out of your league at this point.
   2. You might think you could get around all this by initially
      building your arrow as a tesselated object.  That idea might have
      some merit in future applications, but here you are using
      Sutherland-Hodgeman to do clipping and you have to pass that
      routine a set of ordered points.    If you build one object that
      is a series of triangle vertices to fill an concave object, then
      you will most likely break you Sutherland-Hodgman clipping
   3. You could store your object in a tesselated form and pass EACH
      TRIANGLE through Sutherland-Hodgman, which should result in a
      convex polygon being returned in each case.  While this would be
      very cool, it could force you to completely rethink (and rewrite)
      large sections of your code.

The best course of action at this stage of the game is to tesselate 
AFTER clipping.   This would require you to write a tesselation 
algorithm -- there are many in existence (I have the papers in my office 
or in my files at the house).   I encourage you NOT to do this until 
everything else is working perfectly as the ability to fill the polygon 
will account for less than 4% of the grade on this assignment.  If there 
is interest, we will discuss some options in class on Tuesday.

*Note:*  please do not try and just "dump" a tesselation program's souce 
code from the internet into your program.  You will waste an enormous 
amount of time if you do not understand the intracacies of the algorithm 
and I have already seen how much some of you struggle with computational 
geometry.  Get the code done with a wireframe and then go back and play 
if you have time.  Hear this clearly -- if you do use an algorithm for 
tesselation that is not of your own design, then I expect you to not 
only reference the source in your code, but for you to also submit to me 
the JOURNAL PAPER (not simpy a web page printout) that contains the 
details of the algorithm.  If you do design a "new algorithm",  then you 
better have it commented.

-- 
Andrew J. Pounds, Ph.D.  (pounds at theochem.mercer.edu)
Associate Professor of Chemistry and Computer Science
Mercer University,  Macon, GA 31207   (478) 301-5627

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://theochem.mercer.edu/pipermail/csc315/attachments/20101016/f1e3c689/attachment.html


More information about the csc315 mailing list