CZ2104, Lab 1, due Wed, 16 August 2000

 

This set of exercises lets you get started with OpenGL programming: how to compile a program with make, how to use the glVertex* function to draw polygons, and what the other gl and glut functions might do.  The left-hand side gives the questions; the right column shows you what are expected to hand-in. 

 

All Parts 1, 2, and 3 are compulsory (100 marks).

 

Questions:

 

 

What to hand in:

 

Part 1

 

(1).  Read the manpage on the UNIX make command.  What does make command do?

 

 

1.1: Summarize the make command in two or three sentences.

(2).  Download the sample OpenGL programs from the CZ2104 website.

 

      very_simple.c, simple.c, gasket.c

 

ask your TA for a make file.

Compile C program with the command

 

      make PROG=filename

 

where filename is name of the programs without extension .c.  Run the program and watch the output.

 

 

 

 

 

 

 

 

 

 

 

1.2: Nothing needs to hand in.

 

(3).  Read the code in Makefile, try to explain roughly what it does.  Read the code in very_simple.c, try to guess what each function does?  Where can you find more detail information on OpenGL?

 

1.3: Briefly summarize the meaning of the programs, not more than half a page.

 

 

Part 2

Modify the program simple.c, so that it draws three black equilateral triangles in a white background, as shown below.  The sides of the triangles are all 0.5, with the lower left corner of the lower left triangle at the origin (0,0).

                                 

 

 

 

 

 

 

2: Hand in your code in hardcopy.

 

 

 

Part 3

Generate “Sierpinski square” by subdividing square. 

Take a black square, divide it into 3 by 3 squares, remove the center square (so that the center square becomes white).   Take each of the remaining eight squares, and do the same.  Do this “forever”.

 

It is best to write the drawing as recursive function calls. Refer to Appendix A.2, p.532 for ideas.

 

 

 

3: Hard copy of your code and a screen dump of your graphic, if you do the problem.