
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Due: Thursday September 9th at 12:01am (Wednesday at midnight)
Goal: Write a program that rasterizes lines (using the Bresenham/midpoint algorithm) and outputs them to PPM files. Write a second program that draws the same lines using OpenGL and GLUT.
Problem 1 (10 points): (8 points) Write a program that rasterizes the following lines into a 512 × 512 buffer (in memory), and output the result to a PPM file. The background should be black (i.e., RGB = [0,0,0]). Use a utility program to convert the PPM file to GIF, PNG or BMP to display on your web page (use ppmtogif , ppmtobmp , or xv on Linux systems or GIMP on Windows systems).
(2 points) In a second 512 × 512 image, draw the same five lines, but change colors gradually from one end to the other. For example, draw the line from (0,0) to (511, 511) starting at red and gradually blending to green at (511, 511). I want you to think about and come up with a blending method on your own. There is no right or wrong way to blend here, as long as the color varies gradually over the line. Make sure to use contrasting colors at the endpoints (white & black, red & green, yellow & blue, etc.)
Problem 2 (10 points): (5 points) Write an OpenGL/GLUT program that draws the same lines as in Problem 1 (using the same colors). Using a keyboard callback , allow the user to switch back and forth between the solid lines (glShadeModel(GL FLAT);) and those with gradually varying colors (glShadeModel(GL SMOOTH);) by hitting the key ’ c ’. Capture the result in an image and post on your web page. Make sure to label your images, so I know which is from Problem 1 and which is from Problem 2.
(5 points) Allow the user to draw an additional line by clicking the right mouse button at the two endpoints.
Extra Credit (5 points): Combine both problems into a single OpenGL program. Using a keyboard call- back, allow the user to switch from OpenGL rendering to your own rasterization technique. Make sure to la- bel your window (perhaps using glutSetWindowTitle(char *title); ), so the user knows which mode is active. Use glBegin(GL POINTS); to draw each pixel.