
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: Wednesday September 9 th^ at 11:59pm
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 (using the Bresenham algorithm) 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 (e.g., use ppmtogif , ppmtobmp , or GIMP on Linux systems or GIMP on Windows systems). To reduce data-entry time, these points are available online in an electronic format. (Note: This program should not use OpenGL.)
(2 points) In a second 512 × 512 image, draw the same lines, but change colors gradually from one end to the other. For example, draw the line from (1,1) to (1, 510) starting at red and gradually blending to green at (1, 510). 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 (2 points): Using code from Problem 2, write an OpenGL-based program that displays and updates the current time (i.e., a clock). Don’t make this too hard: use your line drawing routines from above.
NOTE: Please remember to include a “README” file with your submission detailing how to compile, how to run, and any problems that might exist with your submission. Also remember to post result images (but not code!) on your webpage.