Fall 2010
The purpose of this lab is to familiarize you with the code framework we provide, as well as with basic OpenGL drawing commands. You will implement a program that mimics an old screen saver by filling the screen with random two-dimensional geometry.
This project is due at 11:59 PM on Monday, August 30st. Because this is a "practice" lab, it is worth 0 points; however, if you do not complete this lab on time, we will subtract 100 points from your final lab grade.
The program will start out with a blank screen. The user interacts with the program by pressing keys to change the behavior of the program.
The program has four modes: idle, points, lines, and triangles. The behavior in each mode is as follows:
- In idle mode, the program displays a blank screen. Idle mode is set by pressing the number key 0.
- In points mode, the program displays points on the screen. Each point should have a random location (within the program's window) and a random color. Points mode is set by pressing the number key 1.
- In lines mode, the program displays line segments on the screen. The endpoints of the lines should be placed and colored randomly. Lines mode is set by pressing the number key 2.
- In triangles mode, the program displays triangles on the screen. The vertices of the triangles should be placed and colored randomly. Triangles mode is set by pressing the number key 3.
Except during idle mode, new shapes should be added to the screen on each frame. That is, every time the renderFunc() is called, your program should add another point, line, or triangle to the visible image. After enough shapes have been drawn to sufficiently fill the window, the screen should be cleared; drawing should continue. You may decide for yourself what "sufficiently fill" means, but please keep the rate of screen clearance reasonable. The screen should also be cleared whenever the mode is changed.
The program should terminate when the `Esc' key is pressed.
Click here
for an example of this program. Your program does not need to match the example exactly, but it should meet the criteria listed above.
Remember that the framework we provide clears the screen between each call to renderFunc(). Therefore you have to draw all the geometry you want to display each time this function is called- the screen will not remember what you have previously drawn. You might store previously generated vertices in a list so they can all be drawn for each frame.
To get random numbers, you can call the C library function rand(), which returns an integer between 0 and RAND_MAX.
Create a directory lab0. This directory should contain your source code and all files needed to build your program in Visual Studio (or with CMake). Also include a README file with your name and any implementation details you think your grader should know. Please zip this file and follow the lab submission instruction on the class webpage.
Back to Home page.
Modified by Powei Feng
2010-08-26