Lab Assignment 1 -- Demo and writeup due Thursday, Jan. 26 in the Lab Session
CS 5721, Spring Semester, 2006
20 Points
Topics: Emulation of a raster display and introduction to SRGP

The assignment: will have three parts:

  1. Design and implement a program that simulates part of a raster display system -- see Fig 4.18 (page 166) with:
  2. Implement the following routines of SRGP to run on the emulated system of Part 1: SRGP_lineCoord, SRGP_line, SRGP_polylineCoord, SRGP_polyline, SRGP_polygonCoord, and SRGP_polygon -- see Section 2.1.1, pages 27-29.
  3. Write a test ("driver") program that calls the graphics package routines of Part 2. above and prints out "views" of frameBuf (using VideoCont()). A routine ClearFrameBuf() to initialize frameBuf to all 0's may be useful.

Discussion/hints: Here is a possible method for implementing SRGP_lineCoord(x1,y1,x2,y2) (you may have a different way of implementing lines) :

  1. First handle "more horizontal" and "more vertical" cases:
                    if  abs(x2 - x1) > abs(y2 - y1)
                         call xLine(x1, y1, x2, y2)
                    else
                         call yLine(x1, y1, x2, y2)
    
  2. Similarly, for xLine handle left and right starting points:
                    if  x2 > x1
                         call xLineIncrease(x1, y1, x2, y2)
                    else
                         call xLineIncrease(x2, y2, x1, y1)
    
  3. Similarly for yLine...
  4. For xLineIncrease(), you may use Line() on page 75 or MidpointLine() on page 78 -- which only works for slopes between 0 and 1 -- see Ex. 3.2 at the end of Chapter 3.
  5. The "value" that WritePixel() writes should be 1 (unless you do color).

Further Hint: In the past, I received the following question from a student:

> Is it all right if (inside SRGP_polyLineCoord) we call SRGP_lineCoord
> and let it call SRGP_Line, rather than having a SRGP_polyLine
> (or polygon) procedure?
Answer: You need to implement all 6 of the routines, but you can do so as simply as possible (i.e. do as little coding as possible) -- you need not implement each one "from scratch". For example, as you suggest, if you implement SRGP_line, then you can implement SRGP_lineCoord by a single call to SRGP_line (and a small bit of code), and in turn you can implement SRGP_polyLineCoord by a sequence of calls to SRGP_lineCoord (which, as you point out, will automatically call SRGP_line). Then SRGP_polygon can be implemented by one call to SRGP_polyLine and one call to SRGP_line. Similarly for SRGP_polygonCoord.

Actually, I myself would do things slightly differently: I would first implement SRGP_lineCoord "from scratch" and then SRGP_line would be a single call to SRGP_lineCoord, etc...

Other possible help: There are two sample programs, ( lab1sample1 - noninteactive, written by a student, and lab1sample2 - interactive, written by me) in the lab1 directory of the class account: /opt/local/studata/COURSES/cs5721. The README file describes all the files in lab1.

I broke up my C program into main.c, which contains an interactive loop, the SRGP module, mySRGP.h and mySRGP.c, and the interface module that handles user interaction, interface.h and interface.c. I used the Makefile to compile my program.

Extra Challenges/credit: (1 point each)

  1. Implement colors (digits stored in frameBuf <--> , *, O, M, #, etc.). Use a color table -- which will just be an array of these characters (so VideoCont() will place the character colorTab[frameBuf[x][y]] at position (x,y) of the terminal screen).
  2. Use a 1-Dimensional array (like real memory) for frameBuf (requires 1-D <--> 2-D array address conversion routines).
Notes: Extra credit points are much harder to earn than ordinary points. Also, you should implement the regular assignment features first, before trying to implement any extra credit features. The instructor will help you debug the regular assignment features, but you should expect to implement the extra credit mostly "on your own".

What to turn in: Turn in the following items from the Computer Science Lab Report Format:
1. (1 point) The Basic Information (your name, class, section, TA's name, assignment number, and date) can be on a separate cover sheet or as (highlighted) comments at the top of your main program file.
2. (1 point) The Problem Statement is a brief description of The assignment: above. Note: the problem statement can (and should) be in a comment at the top of your main program file.
4. & 5. (5 points) do this for your "line" algorithm
9. (up to 2 points if done) Document the Extra Credit part of your program if you did it (by coded/hand-written comments and highlighting -- as usual).
11. (5 points) Include all program listings and output. These listings should show good style, be appropriately commented, have the important parts highlighted, and include handwritten explanations if it helps the reader's understanding of the code.
13. & 14. (8 points) The most important part. A program run (or separate program runs) should demonstrate that your primitives work correctly. The Test Descriptions are handwritten explanations on these printouts of what each program run demonstrates.
15. Include a description of any Known Bugs if needed. You may be able to gain back lost points by a careful analysis of what went wrong and possible fixes.
16. This is optional (and no points usually), but it is useful to think about Possible Improvements.
17. Comments on the lab assignment are also optional (and again, no points usually), but appreciated!

Important Note: You may discuss algorithms with other students, but the program and lab report should be your own work.


Page URL: http://www.d.umn.edu /~ddunham/cs5721s06/assignments/lab1/assignment.html
Page Author: Doug Dunham
Last Modified: Saturday, 14-Jan-2006 18:41:43 CST
Comments to: ddunham@d.umn.edu