CS 174 Discussion 2
-
Upload
cedric-alston -
Category
Documents
-
view
17 -
download
2
description
Transcript of CS 174 Discussion 2
Gianfranco Doretto April 19, 20021
CS 174 Discussion 2CS 174 Discussion 2TA Gianfranco Doretto
Gianfranco Doretto April 19, 20022
RemindersReminders
Sign and turn in the academic honesty policy: no homework will be graded if you do not do so!
Let me know your preferred email address (grading notification)
Forward your emailUse the mailing list [email protected] an eye on the class website
Gianfranco Doretto April 19, 20023
OpenGL in the LabOpenGL in the Lab
For all your labs, you should NOT use any opengl or glut functions other than the ones already available in the sample program provided (opengl.cc)
1. login to NT box 2. click on “Xsession ugrad.seas” (Solaris) icon on the
desktop 3. login again (same login name and password) 4. invoke a window manager (choose it from the option
menu)5. ftp or copy the skeleton.tar.gz tarball from local
machine to your UNIX directory
Gianfranco Doretto April 19, 20024
OpenGL at Home OpenGL at Home
download and unzip the file glutLibs.zip place the file glut.h in the folder C:\Program Files\
Microsoft Visual Studio\VC98\Include\GL place the file glut.dll in the folder C:\WINDOWS\
system32 place the file glut32.dll in the folder C:\WINDOWS\
system32 place the file glut.lib in the folder C:\Program Files\
Microsoft Visual Studio\VC98\Lib place the file glut32.lib in the folder C:\Program
Files\Microsoft Visual Studio\VC98\Lib
Gianfranco Doretto April 19, 20025
UNIX TutorialUNIX Tutorial
Have a look at the FAQ of the class web page
Gianfranco Doretto April 19, 20026
Submission guidelinesSubmission guidelines Due: 4/25/2002 at 6:00pm No partial credit will be given to programs which
cannot be compiled and tested on ugrad.seas (Solaris)
submit a tarball: source code files, Makefile, input script files, README etc.
Example: your files are located in $(HOME)/lab1 1) cd ~/ 2) tar cvf lab1.tar lab1 3) gzip lab1.tar 4) submit cs174 lab1.tar.gz After you hit the return key, a statement like "submission
successful" will be printed on the screen
Gianfranco Doretto April 19, 20027
README fileREADME file submit a README file with each lab, only if you
are doing the extra credit stuff, or if you are doing something different from what is mentioned in the lab description handout. Also, mention what assumptions you have made to get your lab running.
1. Your name appeared in UCLA record, 2. Your student ID, 3. Your preferred email address4. Your seas login ID, 5. Date and Lab number.
Gianfranco Doretto April 19, 20028
Surce filesSurce files
In particular, you must put down the following information at the top of each program file.
1. Your name appeared in UCLA record 2. Your student ID3. Your preferred email address4. Your seas login ID5. Date and Lab number
Gianfranco Doretto April 19, 20029
MakefileMakefile
In case your makefile gives an error while compiling, try the following command from the command line (everything on one line):
g++ -I/usr/local/glut-3.7b/include -I/usr/include -I/usr/local/gcc-2.95.2/include/g++-3 -I./ -L/usr/local/glut-3.7b/lib/glut -L/usr/lpp/OpenGL/lib -L/lib -L/usr/lib -lGLw -lGLU -lGL -lglut -lXm -lXt -lXext -lX11 -lXmu -lm -o opengl opengl.cc
Gianfranco Doretto April 19, 200210
What does the sample program What does the sample program do?do? It starts up a window of size 400x300, and clears
it. Press the left mouse button a dot is plotted Release the left button another dot is plotted Press the right or the middle mouse button, a
message is printed out k-q exits the program Bring up a larger or smaller window (“opengl
500 500" will bring up a window of size 500x500)
Gianfranco Doretto April 19, 200211
k-L (20%) k-L (20%)
Puts in line drawing mode. A line should be drawn between every two consecutive points you left-click on the window
Midpoint algorithm works for slopes between 0 and 1
Generalizing the algorithm is your job!
Gianfranco Doretto April 19, 200212
k-P (30%)k-P (30%)
Puts in polygon drawing modeA line should be drawn between the
current (left-clicked) point and previous (left-clicked) point. End the sequence of points using the right-click. Complete the polygon by drawing a line between the last point and the first point
Gianfranco Doretto April 19, 200213
k-C (10%)k-C (10%)
Clear the window
Gianfranco Doretto April 19, 200214
k-Q (10%)k-Q (10%)
close the window and quit the program
Gianfranco Doretto April 19, 200215
Any other keys (10%)Any other keys (10%)
print out an appropriate message, notifying the user of the invalid key
Gianfranco Doretto April 19, 200216
Moving/rise window (20%)Moving/rise window (20%)
Your program should be able to handle lowering and raising of the drawing window. Basically, redraw the contents of the window whenever you raise or move your window
You do not need to use dynamic data structures to store an indefinite number of objects (such as points, line, circles, polygons, etc.)
If you want to add some more credits you can handle also the reshaping using the glutReshapeFunc() (look at the code posted on the web for an example that use this function)
Gianfranco Doretto April 19, 200217
Moving/rise window (20%)Moving/rise window (20%)
For the purposes of refreshing your screen (during redraw, etc.), you will need to store information about the lines, polygons, and circles.
Assume an upper limit to each of these:max # of lines : 100max # of polygons : 100max # of lines per polygons : 25max # of circles : 100
Gianfranco Doretto April 19, 200218
Extra credit k-F (10%)Extra credit k-F (10%)
Fill the polygon with RED color
Gianfranco Doretto April 19, 200219
Extra credit: Circle drawing Extra credit: Circle drawing (10%)(10%)Add circle drawing functionality to your
programMark the center of the circle with a
middle-click, then drag the mouse (holding the middle mouse button down), and release the middle mouse button, when you reach the size (radius) of the circle.
Gianfranco Doretto April 19, 200220
DemoDemo
SkeletonExample 1Example 2Example 3