Department of Computer Science
Worcester Polytechnic Institute

CS-543: Computer Graphics
Project 0
Due: Not to be handed in.

Objective: In this project, you will learn some of the basics of OpenGL. The project will not be graded.

Project: The aim of this project is to get your feet wet in OpenGL. You will learn how to install and set up your OpenGL system and perform a few simple, fun tasks. You will mostly be given some readings from the book and be expected to type in an accompanying sample program or cut and paste examples. Follow the instructions and type in code carefully. Note that due to the large number of operating systems and compilers out there, I cannot provide help on all platforms. I will be glad to provide assistance on how to compile your code on ccc.wpi.edu or MinGW. You can develop on any platform with C/C++ and OpenGL, but grading will be done on CCC, so it is your responsibility to get it working there.

Setup: Here is a Makefile that works on ccc.wpi.edu, here is a Makefile for Windows, and here is a Makefile for Mac OSX. These are just samples, and assume that your OpenGL program is in a file called cs543_proj0.cpp. Change the names accordingly for your program.

You can either rename (or copy) the makefile you will use to "Makefile", or use the "-f" option to make, (e.g., "make -f Makefile.windows"). Here's a sample output from using Makefile.unix on ccc.wpi.edu, which has been renamed "Makefile":

> ls
cs543_proj0.cpp  Makefile
> make
g++ -o proj0 cs543_proj0.cpp -lglut -lGL -lGLU -L/usr/X11R6/lib -lX11 -lXmu -lm
> ls
cs543_proj0.cpp  proj0  Makefile
> ./proj0
[program runs]
> make
make: `proj0' is up to date.
> make clean
rm proj0

Coding:
  1. Draw three dots: Read section 2.2 (page 47) of Hill book. Use the sample code in figure 2.11 (page 51) of Hill book to write a program for drawing three dots to the screen. Name the file appropriately and save it (e.g. proj0_ThreeDots.cpp). Compile and run the program!!
  2. Sierpinski Gasket: Read example 2.2.2 (page 52) of Hill book. Use the following skeleton of the Sierpinski gasket to write a program which draws the Sierpinski gasket. The bodies of the GLIntPoint class, the random function, the drawDot function and the Sierpinski function (figure 2.15) have all been omitted. Type them in from example 2.2.2 and the appropriate figures in the text. Compile and run the program!!!

    To make your Sierpinski gasket prettier, in the for loop in the Sierpinski( ) function, change the number of iterations from 1,000 to 50,000. Drawing point size should be at 1.

  3. Reading and drawing polyline files: Read section 2.3, especially example 2.3.2 on page 61 of Hill book to draw polyline files.

    Using the following skeleton write a program to read in a polyline file and draw it to the screen. The body of the drawPolyLineFile function has been omitted. Type it in from figure 2.24 on page 62. Save and use the polyLine file dino.dat for your work.

    The basic structure of a GRS file 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.
    • Note that a lot of the GRS files start with comments. You should read them in and ignore them in your program.
    • The format for dino.dat is a little different in that it doesn't have the window dimensions (or comments) right at the top. Therefore, off the bat, a program which reads other GRS files without problems will have new problems with your old dino.dat file. You can either throw in a dummy extents window at the top of dino.dat or come up with a solution that works.

      Hint: A value of ( 0, 640, 0, 480 ) should work!!

    Compile and run the program!!

Note: Make sure you read the examples in the book before typing in the examples.


Academic
Honesty:
Remember the policy on Academic Honesty: You may discuss the assignment with others, but you are to do your own work. The official WPI statement for Academic Honesty can be accessed HERE.


Back to course page.