[CSC 315] Class on Thursday

Andrew J. Pounds pounds_aj at mercer.edu
Wed Oct 28 14:27:49 EDT 2026


Class - I have had multiple requests for office meetings and have been 
doing my best to respond to issues on Anvil in a timely manner.  Since 
your project is coming due I would like to designate tomorrow as a work 
day to accommodate those who could not come to my office hours.

As you continue to develop your code for the second project I want to 
offer a few "hints"...

 1. Don't be afraid of making global variables to hold the state of your
    program.  For example, in my code that draws the triangles I have to
    decide if they are to filled or if I am going to just draw the
    triagles.  So I have code line this...

     if ( FILL ) {
           for (i=1; i<numTriangles+1; i++ ){

             glBegin(GL_POLYGON);
                 glVertex2f( TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex1.x,
                             TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex1.y );
                 glVertex2f( TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex2.x,
                             TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex2.y );
                 glVertex2f( TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex3.x,
                             TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex3.y );
             glEnd();
         }
     }
         else {
             for (i=1; i<numTriangles+1; i++ ){
                 glBegin(GL_LINE_LOOP);
                 glVertex2f( TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex1.x,
                             TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex1.y );
                 glVertex2f( TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex2.x,
                             TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex2.y );
                 glVertex2f( TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex3.x,
                             TRIANGLE_TYPE_2D_findNodeN(triangles,i)->triangle.vertex3.y );
                 glEnd();
             }
         }
  }


 2. Let your keyboard and mouse functions set the state of the global
    variables.
 3. Feel free to use multiple arrays to help you build out your tree.  I
    have one for the full circle, one for the canopy, and then one for
    the tree.
 4. When you call the clipping algorithm (Southerland Hodgman) you
    generally have to call it multiple times in succession with
    different clip edges.  For example, in the following code I am
    clipping against the four edges of a rectangle.  I call the same
    function, but I pass it in the clipped array of points from the
    previous call and then swap on the next call.

edge[0].x=VIEWPORT_MIN; edge[0].y=VIEWPORT_MAX; edge[1].x=VIEWPORT_MIN; 
edge[1].y=VIEWPORT_MIN;
SutherlandHodgmanPolygonClip(inVertex,outVertex,*inlength,outlength,eptr); 
edge[0].x=VIEWPORT_MIN; edge[0].y=VIEWPORT_MIN; edge[1].x=VIEWPORT_MAX; 
edge[1].y=VIEWPORT_MIN; 
SutherlandHodgmanPolygonClip(outVertex,inVertex,*outlength,inlength,eptr); 
edge[0].x=VIEWPORT_MAX; edge[0].y=VIEWPORT_MIN; edge[1].x=VIEWPORT_MAX; 
edge[1].y=VIEWPORT_MAX; 
SutherlandHodgmanPolygonClip(inVertex,outVertex,*inlength,outlength,eptr); 
edge[0].x=VIEWPORT_MAX; edge[0].y=VIEWPORT_MAX; edge[1].x=VIEWPORT_MIN; 
edge[1].y=VIEWPORT_MAX; 
SutherlandHodgmanPolygonClip(outVertex,inVertex,*outlength,inlength,eptr);

 4. TRANSFORM BEFORE YOU CLIP
 5. CLIP BEFORE YOU TESSELATE
 6. I would like you code somewhat segmented into separate files.
 7. I need to be able simply type "make" to build your code.
 8. I am not worried too much about performance speed -- but if it is
    excessive (like you tree never moves once it is tesselated) I will
    have to take that into account.  Point here is that you need to
    focus more on functinality than trying to make it fast.

I'll be in the lab tomorrow morning if anyone wants to come meet with me.


-- 
*Andrew J. Pounds, Ph.D.*
/Professor of Chemistry and Computer Science/
/Director of the Computational Science Program/
/Mercer University, Macon, GA, 31207 (478) 301-5627 /
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc315/attachments/20261028/a4d4866e/attachment.htm>


More information about the csc315 mailing list