Programming Assignment 1

Due Monday, September 25 at 11:59pm

This assignment will get you started as an OpenGL programmer, while introducing you to basic concepts in interactive graphics programming. You will develop a polygon drawing tool that allows the user to draw, fill, and modify a polygon given mouse input.   In this assignment you can assume that polygons are simple (no self-intersections).

Start programming early.

Get Some Files

Some basic functions and the polygon tool's main program are provided for you. So, before you begin programming, you will need to download source files: You will also need appropriate files to compile and link your program.  The workspace for Visual C++ 6.0 is provided here:
By copying the above files, you have almost everything you'll need to build your own polygon tool. You are expected to complete the program by providing three missing functions using the code templates. There are comments in the template files that will help guide you in writing your own subroutines.  

Run the Example Sketch Tool

An example of a fully functioning sketch tool is available: Run the example working sketch tool to see how your program should work. The user interface to the program is provided through mouse buttons and keyboard:

The Code You Write

You are expected to write three new functions based on the templates provided:
  1. Write a function that uses the even/odd parity rule to determine if a given point is inside a polygon. You can assume that a point on the polygon boundary is considered "inside."
  2. Write a function that determines whether a polygon is concave, using one of the algorithms described in the textbook.
  3. Write a function that subdivides a concave polygon into convex polygons and draws them (via openGL).  Use any of the subdivision algorithms described in the Hearn and Baker textbook or in class. 

Required for CS680 Students

support polygons with holes.  Algorithms for this will be described in class.

Extra Credit

For extra credit, detect when a polygon is self-intersecting (not simple) and display a text message in the GLUT window. 

Test Cases

A number of test cases are provided. They appear each time you press the T key.  By pressing the S key, you can toggle the inside/outside test, which for the current polygon provides a color-coded display of insidePoly for all pixels in the current window. You can preview these test cases in the working example and compare the results with those of your own implementation.  These should help you in debugging your program.

Demo

Part of your grade for this programming assignment will be based on your giving a short demo (5 minutes) in the CS instruction laboratory. You will be expected to talk about how your program works, and we will see how well your program performs on the aforementioned test cases, as well as some additional, surprise test examples. Demos will be scheduled during the lab section meetings, after the due date.   You will be asked to sign up for a demo slot on a signup sheet that will be circulated in class before the assignment due date.
 

Source Code Submission

Your program's source files are to be submitted electronically. Use the gsubmit program on the CS cluster.

The code you submit should conform with the program assignment guidelines.

Grading (Out of 100 points)

CS480

Working inside/outside test, all cases 25 points
Working concave/convex test, all cases 25 points
Subdivision and shaded drawing of convext polygons
40 points
Programming style  10 points
Dectect self-intersecting polygons 10 extra credit 

CS680

Working inside/outside test, all cases 15 points
Working concave/convex test, all cases 15 points
Subdivision and shaded drawing of convext polygons
30 points
Programming style  10 points
Polygons with holes 30 points 
Dectect self-intersecting polygons
10 extra credit

Late Assignment Policy

Late programming projects and problem sets will be levied a late penalty of 10% per day (up to three days). After three days, no credit will be given.

Collaboration/Academic Honesty

All course participants must adhere to the CAS Academic Conduct Code. All instances of academic dishonesty will be reported to the academic conduct committee.