Docsity

Assignment 1 Problems for Computer Graphics | CSC 413, Assignments of Computer Graphics

Toggle sidebar
bg1
TFH, 1/21/2009
SCHOOL OF COMPUTER & INFORMATION SCIENCES
CSC 413Computer Graphics
Assignment 1, due Monday, Feb 2
You are to simulate a binary raster (pixel array) by writing an OpenGL program, using GLUT, to display
an array of ―logical pixels‖ (squares). The logical pixels have coordinates from –n to +n from left to right,
and from –n to +n from bottom to top, with n having a value of 5. Each pixel has an indexed color (you
can make an array of colors—you will only need two for this assignment). For the moment, colors can be
0 and 1, representing say, red and green. The client area should be 550×550.
You should use C++ with good object-oriented program design (even though OpenGL itself is not object-
oriented).Your model could involve a class which simulates display memory (e.g., named
FrameBuffer) containing a (2n+1)×(2n+1) matrix (2D array) with elements representing the pixel
color. You can also have a class (named, say Canvas) which is the visual display (and manipulation
interface) of the FrameBuffer. This class should provide members to
1. reset all pixels, clear(c) (i.e., set all pixels to color index c)
2. set a given pixel to a given color, setPixel(x,y,c) (c is the color index).
3. get the color of a given pixel, getPixel(x,y).
4. display the raster, display().
The raster should randomly invert pixels, one at a time. This can be done on the idle event, whose call-
back (event handler) is registered by the glutIdleFunc. Don’t forget to call glutPostRedisplay() to
cause the client area to be repainted.
The behavior of the program should be as in the executable (dynamic specification) given on course web
site. This first program is non-interactive. It will, in the next assignment, be extended to be interactive by
being able to:
1. change the value of n,
2. resize the window (rather than being fixed at 550×550),
3. click on a ―pixel‖ to invert its color. (random inverting during idle will be removed).

Partial preview of the text

Download Assignment 1 Problems for Computer Graphics | CSC 413 and more Assignments Computer Graphics in PDF only on Docsity!

TFH, 1/21/

SCHOOL OF COMPUTER & INFORMATION SCIENCES CSC 413Computer Graphics Assignment 1, due Monday, Feb 2

You are to simulate a binary raster (pixel array) by writing an OpenGL program, using GLUT, to display an array of ―logical pixels‖ (squares). The logical pixels have coordinates from – n to + n from left to right, and from – n to + n from bottom to top, with n having a value of 5. Each pixel has an indexed color (you can make an array of colors—you will only need two for this assignment). For the moment, colors can be 0 and 1, representing say, red and green. The client area should be 550×550.

You should use C++ with good object-oriented program design (even though OpenGL itself is not object- oriented).Your model could involve a class which simulates display memory (e.g., named FrameBuffer) containing a (2 n+ 1)×(2n+1) matrix (2D array) with elements representing the pixel color. You can also have a class (named, say Canvas) which is the visual display (and manipulation interface) of the FrameBuffer. This class should provide members to

  1. reset all pixels, clear(c) (i.e., set all pixels to color index c)
  2. set a given pixel to a given color, setPixel(x,y,c) (c is the color index).
  3. get the color of a given pixel, getPixel(x,y).
  4. display the raster, display().

The raster should randomly invert pixels, one at a time. This can be done on the idle event, whose call- back (event handler) is registered by the glutIdleFunc. Don’t forget to call glutPostRedisplay() to cause the client area to be repainted.

The behavior of the program should be as in the executable (dynamic specification) given on course web site. This first program is non-interactive. It will, in the next assignment, be extended to be interactive by being able to:

  1. change the value of n,
  2. resize the window (rather than being fixed at 550×550),
  3. click on a ―pixel‖ to invert its color. (random inverting during idle will be removed).