In this project, you will implement some of the 2D drawing routines we have been discussing in class. This will help improve your understanding of these algorithms. The assignment is written for implementation in C or in C++, though you do have the option to implement it whatever langauge you feel most comfortable with (as long as it supports OpenGL, or minimally the drawing of a pixel on a 2D image.).
Also note that you will not be implementing a main program; instead, your reimplementations of the routines described below will be tested with a set of driver programs I will provide.
Function | Description |
---|---|
void
drawLine(int x0, int y0, int x1, int y1) |
Draw
a line from vertex (x0,y0) to vertex (x1,y1) .
|
void drawPolygon(int
n, int x[], int y[]) |
Draw
a filled polygon.
The polygon has n distinct vertices.
The coordinates of the vertices making up the polygon are stored in the
x
and y
arrays. The ith vertex
will have coordinate (x[i], y[i])
|
void clipPolygon(int
in, int inx[], int iny[], int *out, int outx[], int
outy[], int x0, int y0, int x1, int y1) |
Clip
the polygon with vertex count in and
vertices inx/iny
against the rectangular clipping region
specified by lower-left corner (x0,y0) and
upper-right
corner (x1,y1) .
The resulting vertices are placed in outx/outy , with the
vertex count placed in out . |
File | Description |
drawStuff.c | Default implementations of the functions that you need to implement. These default implementations make use of OpenGL calls. They are supplied so that you might compile the test programs and see how they should work. Note that the implementation provided for clipPolygon is especially dumb and will not clip correctly. You can use this file as a template, and replace function code with your implementation. |
setPixel.c | Implementation of setPixel(). Recall that you must use this function in your implementation. No OpenGL calls allowed! |
header.mak | If you plan on using makemake or gmakemake on the Suns. |
lineTest.c | Test program for line drawing. |
fillTest.c | Test program for polygon fill. |
clipTest.c | Test program for clipping algorithm. |
NOTES:
drawLine
may occur in any
order -
that is, there is no guarantee that (x0,y0)
is the
leftmost vertex of the line segment.
Vertices that specify polygons may occur in either clockwise or
counter-clockwise order. Filename | Description |
drawStuff.c | Contains implementations of the routines that need to be written. Feel free to use the supplied drawStuff.c as a template, replacing the original code with your implementation |
aux files | Any additional files that might be needed for your implementation (optional) |
README | Indicate on what platform you tested your implementation and provide additional info I may need to know (e.g. auxillary libraries used) in order to build and run your assignment. |
last
updated
09/30/09