CS 5600 - Spring 2013

Homework Assignment 1

Line and circle drawing (100 points)

Handed out: Jan. 17, 2013
Due: Jan. 30, 2013, 23:59

You will write a program that draws lines and circles using the bresenham algorithms.


Use the program found on getting started as a guide to using OpenGL. 

This program draws a 256x256 white square in the middle of a 512x512 window. 

Please use the void drawPoint(x,y,r,g,b) function to draw your pixels.  x and y are ints while r,g,b are floats.

You may not use OpenGL line / circle drawing command but must use the drawPoint subroutine

 

1. You program should compile and run on the machines CADE.  

I will grade in the CADE so if your program does not compile and run, I will not be able to grade it. 

Please check this before handing in your program.

 

2. You should use a 512 x 512 window-size as in the example program.

3. You should read an input file (file name is the first parameter).
For example: lab2.exe line_file

You can set the parameters in Visual Studio.  Ask if you don’t know how.

The input file has the format:
LINE  X0    Y0        X1  Y1   r1  g1    b1   r2   g2 b2
CIRCLE X0    Y0  R    r g b
Where all parameters are floats except for the strings: LINE and CIRCLE.
You should assume 'white-space' between strings (no set spacing)
For example: (white line, gray circle, red line)
LINE  0.0   0.0    10.2 12.4      1.0     1.0 1.0        1.0      1.0   1.0
CIRCLE   5.0        4.5        2.6        0.75 0.75 0.75
LINE 0.0 20.0 20.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0

For CIRCLE, the X0 Y0 defines the center of the circle while the R defines the radius.

There may be multiple lines and circles in the input file, such as in this example

Note, the line or circle may have rasterized points which are outside of the viewport (window).

4. The background (clear color) should be a neutral grey: 0.33 for example.

5. Include a writeup documentation for the assignment discussing:

what you learned,

problems you had,

any issues with your solution,

how to run your solution,

number of hours spent on the solution

6. Extra credit if you interpolate the color along the line.

Output

The program should draw its output to an OpenGL window of size 512x512 as in the example program.

Submission

use the handin routine in the CADE Lab. You can with zip or tar your solution. You should comment your code appropriately and hand in a web-page that will serve as complete documentation. Please include a paragraph of difficulties, how much time this assignment took, and a paragraph of what you learned in this assignment.

The handin name for this lab is "lab1".

Windows users should use the Zip utility and handin a single zipped file. Unix users should use the tar program to do the same. We will recompile the programs to grade them. Make sure your workspace/program will compile for us. That is, be careful about your user-specific pathname variables! If you do this on a home machine, please allow sufficient time for porting to the machines in the CADE on which we will grade based on compiling and running.

Due to a bug in the handin program, do not include spaces in the names of the files that you submit, otherwise we will not receive them. For instance, "no spaces.txt" is not a valid filename and would not be received, while "no_spaces.txt" is valid. Please keep this in mind while handing in your assignment.