WPI Computer Science Department

Computer Science Department
------------------------------------------

CS 543 Homework 1 Fall Semester 2011
Due by Tuesday, September 20, 2011 by class time (10/100 points)


Homework 1: Interactive 2D drawing viewer

The aim of this project is to write a program that can render various 2D drawings including fractals and polylines. The project shall also explore keyboard interaction.

Homework 1 Preparation

Step 1. Install visual Studio 10: If you are working on any WPI CCC Windows machine Visual Studio 10 should already be installed. Check this! If you are using your own machine, you can obtain a copy of Visual Studio 10 from the [ WPI CCC ]

Step 2. Install FreeGLUT and GLEW: Follow instructions [HERE] to install FreeGLUT and GLEW

Freeglut is available at:
http://www.transmissionzero.co.uk/software/freeglut-devel/

GLEW is available at:
http://glew.sourceforge.net/index.html

Note: The installation instructions above require that you have access to the Windows system directory and Visual C++ include and lib folders. If you are unable to access any of these folders, as a shortcut, you can simply include your GLEW and GLUT headers, library and DLL files into your program's Visual Studio project.

Step 3. Test your FreeGLUT and GLEW installations: Test your Visual studio, FreeGLUT and GLEW installations by downloading the following Visual Studio project which is the sierpinski gasket example in chapter 2 of the course textbook. After downloading the zip file, go to the folder sierpinski_test_program\ and open (double-click) the "6E test.sln" Visual studio solution. Once the solution is loaded, compile the solution and run the executable which should be located in the folder sierpinski_test\program\Release. A working visual Studio 10 solution containing the Sierpinski gasket is provided below

Visual Studio 10 Solution of Sierpinski Gasket Program in Chapter 2

Step 4. Render the Fern: Modify the Sierpinski gasket program so that when you run your program, instead of the sierpinski gasket, the fractal called the Fern is drawn. A description of the Fern now follows.
{Ref: Peitgen: Science of Fractals, p.221 ff}
{Barnsley & Sloan, "A Better way to Compress Images"
 BYTE, Jan 1988, p.215}

  {The four affine transformations:}
  {taken from Barnsley & Sloan p.217}
   a[1]:= 0.0; b[1] := 0.0; c[1] := 0.0; d[1] := 0.16;
  tx[1] := 0.0; ty[1] := 0.0;

  a[2]:= 0.2; b[2] := 0.23; c[2] :=-0.26; d[2] := 0.22;
  tx[2] := 0.0; ty[2] := 1.6;

  a[3]:= -0.15; b[3] := 0.26; c[3] := 0.28; d[3] := 0.24;
  tx[3] := 0.0; ty[3] := 0.44;

  a[4]:= 0.85; b[4] := -0.04; c[4] := 0.04; d[4] := 0.85;
  tx[4] := 0.0; ty[4] := 1.6;

--------------------------------------

Choose index randomly to be:
        1 with probability .01
        2 with prob. .07
        3 with prob. .07
        4 with prob. .85

Each new point (new.x,new.y) is formed from the prior point
(old.x,old.y) using the rule:

    new.x := a[index] * old.x + c[index] * old.y + tx[index];
    new.y := b[index] * old.x + d[index] * old.y + ty[index];

and a dot is drawn at point new. The initial point is  old = (0.0, 0.0).
Step 5. Modify the program so that it can read in and draw the following polyline files: The polyline files below are in the GRS format, a homegrown format:

dragon.dat
usa.dat
vinci.dat

The structure of GRS files is:

  • a number of comment lines, followed by a line starting with at least one asterisk: '*'.
  • The "extent" of the figure: (left, top, right, bottom).
  • The number of polylines in the figure.
  • The list of polylines: each starts with the number of points in the polyline, followed by the (x, y) pairs for each point.

Summary of Your program behavior

After the practice, now re-organize your program to have the following behavior. When program starts as default, the Fern is drawn. Your program should then respond to the following key strokes
  • key S: Clear screen and draw Sierpinski Gasket
  • Key F: Clear screen and draw the Fern
  • Key U: Clear screen and draw the USA polyline
  • key D: Clear screen and draw the dragon polyline
  • key V: Clear screen and draw the Vinci polyline
Notes: No OpenGL fixed function commands (glBegin, glVertex, etc) or immediate mode drawing commandds should be used in your program. All drawing should be done using shaders, retained mode and Vertex Buffer Objects, similar to the Sierpinski Gasket program


General Hints

Here are a more few hints you might find useful:
  • In order for your program to respond to keyboard strokes, you will need to write and register a keyboard callback function.

Submitting Your Work

Make sure to double-check that everything works before submitting. Submit all your executable and source files. Put all your work files (Visual Studio solution, OpenGL program, shaders, executable and input files into a folder and zip it. Essentially, after your project is complete, just zip the project directory created by Visual Studio. If the filesize is less than 10MB, you can email me the file. If the final zip file is larger than 10MB, put it in a webspace and email me its URL.

Create documentation for your program and submit it along with the project inside the zip file. Your documentation can be either a pure ASCII text or Microsoft Word file. The documentation does not have to be long. Briefly describe the structure of your program, what each file turned in contains. Explain briefly what each module does and tie in your filenames. Most importantly, give clear instructions on how to compile and run your program. MAKE SURE IT RUNSbefore submission. Name your zip file according to the convention FirstName_lastName_hw1.zip


[Feedback] [Search Our Web] [Help & Index]

[Return to the WPI Homepage] [Return to CS Homepage]

mailto:emmanuel@cs.wpi.edu