Assignment 3: Introduction to Computer Graphics - Triangle Rendering - Prof. Christopher W, Assignments of Computer Graphics

An assignment for the introduction to computer graphics course, fall 2004 (22c:151). Students are required to write programs for scan converting triangles and rendering them using opengl and glut. The assignment includes drawing specific triangles with given vertices and colors, as well as rendering white lines. The goal is to output the results to ppm files for problem 1 and capture images for problem 2, which should be posted on a webpage.

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-lig-1
koofers-user-lig-1 🇺🇸

5

(1)

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Fall 2004
22C:151 Introduction to Computer Graphics
Assignment 3
Due: Thursday September 16th at 12:01am (Wednesday at midnight)
Goal: Write a program that scan converts triangles and outputs them to a PPM file. Write a second program that draws
the same triangles using OpenGL and GLUT.
Problem 1 (10 points): Write a program that draws the following triangles into a 512 ×512 buffer (in memory).
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).
Awhite triangle with vertices (5, 5), (35, 5), and (35, 35)
Ared triangle with vertices (5, 500), (30, 470), and (55, 500)
Agreen triangle with vertices (5, 100), (75, 70), and (45, 140)
Ablue triangle with vertices (80, 70), (150, 100), and (110, 140)
A triangle with a red vertex at (430, 500), a green vertex at (500, 430), and a blue vertex at (510, 510)
A triangle with a yellow vertex at (200, 10), a blue vertex at (400, 40), and a white vertex at (350, 50)
A triangle with a purple vertex at (300, 300), a black vertex at (400, 300), and a black vertexat (300, 400)
A triangle with a green vertex at (300, 400), a green vertex at (400, 300), and a black vertex at (400, 400)
Also draw two white lines (use code from Homework 2) from (300, 399) to (400, 399) and from (299, 300) to
(299, 400)
Problem 2 (10 points): Write an OpenGL/GLUT program that draws the same triangles (and lines) as in Problem
1, using the same colors. Capture the result in an image and post it on your web page. Make sure to label your images,
so I know which is from Problem 1 and which is from Problem 2.
NOTE: Feel free to combine these problems into a single program, with an GLUT keyboard callback to switch
from OpenGL rendering to your scan conversion (as per the extra credit from Homework 2), making sure to label
which approach is currently being displayed.
Problem 3 (0 points): How long did this assignment take you? (E-mail answers to [email protected])
Answering is optional, but will help me gauge the class which should help you in the long run.

Partial preview of the text

Download Assignment 3: Introduction to Computer Graphics - Triangle Rendering - Prof. Christopher W and more Assignments Computer Graphics in PDF only on Docsity!

Fall 2004

22C:151 Introduction to Computer Graphics

Assignment 3

Due: Thursday September 16th at 12:01am (Wednesday at midnight)

Goal: Write a program that scan converts triangles and outputs them to a PPM file. Write a second program that draws the same triangles using OpenGL and GLUT.

Problem 1 (10 points): Write a program that draws the following triangles into a 512 × 512 buffer (in memory). 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).

  • A white triangle with vertices (5, 5), (35, 5), and (35, 35)
  • A red triangle with vertices (5, 500), (30, 470), and (55, 500)
  • A green triangle with vertices (5, 100), (75, 70), and (45, 140)
  • A blue triangle with vertices (80, 70), (150, 100), and (110, 140)
  • A triangle with a red vertex at (430, 500), a green vertex at (500, 430), and a blue vertex at (510, 510)
  • A triangle with a yellow vertex at (200, 10), a blue vertex at (400, 40), and a white vertex at (350, 50)
  • A triangle with a purple vertex at (300, 300), a black vertex at (400, 300), and a black vertex at (300, 400)
  • A triangle with a green vertex at (300, 400), a green vertex at (400, 300), and a black vertex at (400, 400)
  • Also draw two white lines (use code from Homework 2) from (300, 399) to (400, 399) and from (299, 300) to (299, 400)

Problem 2 (10 points): Write an OpenGL/GLUT program that draws the same triangles (and lines) as in Problem 1, using the same colors. Capture the result in an image and post it on your web page. Make sure to label your images, so I know which is from Problem 1 and which is from Problem 2.

NOTE: Feel free to combine these problems into a single program, with an GLUT keyboard callback to switch from OpenGL rendering to your scan conversion (as per the extra credit from Homework 2), making sure to label which approach is currently being displayed.

Problem 3 (0 points): How long did this assignment take you? (E-mail answers to [email protected]) Answering is optional, but will help me gauge the class — which should help you in the long run.