assignments-programpractice

Programming Assignment 1: Practice

The goal of this assignment is to give you a chance to practice usingthe tools that we’ll be using in CS559 for our “real” programs. Thecontent of the assignment is pretty minimal, but it will force you towrite C++ programs using the CSL supported tools, to read and writeimages using our library, to use OpenGL and FlTk, and to turn thingsin correctly for the class.

Specifically, you need to write programs that:

  1. Read in an image, make a small green square in the middle, and writeit back out. This program should take 2 command line arguments: thename of the input file and the name of the output file.
  2. Open a window and draw a picture in it using OpenGL. The programdoesn’t need to be interactive except that it should quit when theuser presses escape or closes the window.

As you can see, the requirements are really light. This is more aboutmaking sure you can run the compiler, link to the libraries, turnthings in correctly, etc.

1.@ Part 1 - Read, Modify, Write an Image

Your program should take 2 command line arguments (both filenames).

You will need to use some library for reading and writing images. Weprovide a library for reading and writing Targa (TGA) images. Thislibrary is simple, and we recommend using it. There are BAD LINK for getting started with Visual Studio, along with a BAD LINK for using the library

Your program should modify the image it reads so that there is a smallgreen square in the middle. The exact details aren’t important. You’llwrite programs that do more interesting things with images soon.

2.@ Part 2 - Draw a Picture in OpenGL

Your program should open a window, and draw a picture in it. Thewindow should stay open until the user closes it. The window shouldget redrawn properly if it is uncovered, etc.

You’ll need to use some library for creating windows. We recommendFlTk, and have provided a BAD LINK.

You should do the drawing using OpenGL. You don’t need to do anythingfancy - just draw a few lines and polygons to get the hang of it. Itdoesn’t need to be 3D, or have lighting, or use any fancy features -you’ll have plenty of opportunities to do that later.

Your picture must be a picture of something - you can tell us what itis. It has to have lines and polygons, and it has to have differentcolors in it.

Of course, if you want to make a really cool picture, that’s fine byus and we won’t complain. (in fact, we’ll thank you for making ourlife interesting). How cool your picture is won’t effect your grade(providing that your program meets the minimum requirements).

3.@ What to turn in

You need to follow the rules for turning things in for thisclass. Look over the policies page.

For each program you write, be sure to turn in:

  • The visual studio solution and project files (.vcproj and .sln)
  • All the source code
  • For the imageio program, you should include the libtarga files

You should also turn in a readme file that explains things (includingwhat your picture is supposed to be).

You should include a screen shot (in JPEG or PNG format) of whatpart 2 does. (Use a screen capture program - Alt-PrintScreen andpasting into an image editor works)

You should include an input/output pair of what your program 1does. Call these input.tga and output.tga. Input.tga should be nobigger than 200 pixels on a side (TGA files are not compressed, sothey get to be quite big).

Remember, you don’t turn in executables, debugging information, etc.

Your handin directories are in /p/course/cs559-gleicher/handin/LOGIN (where LOGIN is your cs user ID). Within that directory, there should be directories P0-tga and P0-gl (for “program 0” one directory for your targa read/write, and one for the open gl part).

If your handin directories aren’t in place, contact the TA and he’ll make them for you.

4.@ How will we evaluate this?

You will be graded based on:

  1. Did you follow the directions? (turn in the right things, haveprograms that meet the basic requirements, have appropriatedocumentation)
  2. Can the grader tell what your program does by reading it?

5.@ If you really get stuck

The main thing we’re looking for is to make sure you can get these basic mechanic things to work. So, if you can’t sort out how exactly to draw something with OpenGL, or how to make the green square in an image, here is some example code that actually is a complete solution for the assignment. (you still should make sure you can get it to compile and run). For the OpenGL portion, here is the solution. For the image portion, here is a solution.

Page last modified on September 18, 2008, at 06:06 PM