JMU
Programming Assignment 3


1 Overview: For this assignment you must use your Matrix and Vector classes/templates from programming assignment 2 in a 2-D rasterizer (and supporting classes). Specifically, you must write a Geometry template and a Rasterizer2D class.
2 Getting Started: You should not have to make any changes to your Matrix and Vector classes/templates. Hence, you should not have to copy them -- you should just be able to #include them from the appropriate directory/folder.
3 Existing Classes/Templates/structs: A few different classes/templates/structs have been created for you.

The first is a simple struct that encapsulates RGB colors. It should be self-explanatory.

Color ( Header )

The second is a simple (and not robust) encapsulation of a window that uses SDL. Note that, depending on your envrionment you may need to change the #include for SDL. Hopefully, you will not need to make changes to this class (it has been used with all majors OSs), but you should feel free to make changes if necessary.

GraphicsWindow ( Header , Implementation )

The third is a simple (and not robust) encapsulation of a frame buffer that uses SDL. It uses traditional Euclidean coordinates with the origin of the coordinate system in the middle of the GraphicsWindow. Most importantly, it provides the ability to set the color of individual pixels. Because of slight differences between the way SDL works under different OSs, there are some lines that need to be commented-out/included for different OSs. This should be apparent from the source code. Also, depending on your envrionment you may need to change the #include for SDL. Hopefully, you will not need to make major changes to this class (it has been used with all majors OSs), but you should feel free to make changes if necessary.

FrameBuffer ( Header , Implementation )

4 Detailed Specification: The detailed specifications/designs for the Geometry template and the Rasterizer2D classes are available on-line:

Geometry ( Template )

Rasterizer2D ( Header )

Be careful about the dimensionality of the functions in the Geometry template. Even though this assignment is about 2-D rasterization, some of the functions in this template are N-dimensional. Also, note that you may not need to use all of the methods in the Geometry template in your Rasterizer2D. Determining which you need and which you don't should help you assess your understanding of the material.

5 A Note about SDL: SDL has a complete 2-D graphics library but you must not use it. We are using SDL exclusively as a simple (platform independent) windowing system.
6 Unit Testing: You must create traditional automated unit tests for all methods that do not use the FrameBuffer

You must also create "visual" unit tests for all methods that do use the FrameBuffer class (i.e., unit tests that you can verify by looking at the FrameBuffer). While one could create an alternative headless (i.e., off-screen) FrameBuffer class for automated testing, that is beyond the scope of this course. At a minimum, you must test:

7 Integration Testing: You must use the following driver for integration testing:

The output from this test must look like the following:

screenshot.png

Note that, while this image looks 3-D, it does not involve any 3D rasterization techniques.

8 Submission: In addition to the normal materials, your submission must include: hardcopy output of your unit tests and a hardcopy (of a screenshot) of the integration test.
9 Grading: Your implementation must work correctly for you to receive credit for this assignment.
10 Questions to think About: The Geometry template could have been designed in a variety of different ways. You might want to think about the following questions:
  1. Which \(N \times 1\) and/or \(1 \times N\)Matrix objects could, instead, have been Vector objects? Should they have been?
  2. area(), inside(), and toImplict() are templated so that they are one-to-one with Matrix. What would happen if they weren't?
  3. inside() is passed three "vectors" containing the vertices rather than a single Matrix. Would it be better to pass a Matrix?

Copyright 2014