Lab Work - Getting Started / Solar demo
Goals: Learn how to copy files from the public directory, how to compile and run programs with Microsoft Visual C++, how to edit source files.
Copying from the public directory. After logging in, find the C++ Projects folder in the public directory (which is drive P:). Copy the entire C++ Projects folder into your personal disk space (in drive H:). The best method for copying files and folders is right-clicking on the file or folder to be copied, and selecting Copy from the pop-up menu, then going to where you want to copy to, and right-clicking again and selecting Paste.
Running an OpenGL program. Go into the directory C++
Projects/Solar in your H: directory. In the subdirectory Debug,
run the program solar.exe. You should get a window showing a simple
solar system with a sun, earth and moon: with the earth revolving around the sun and the
moon revolving around the earth. You may use the up-arrow and down-arrow keys to
control the speed of the solar system.
Congratulations! You have now successfully run an OpenGL program.
Compiling and running solar.exe. Before running the
compiler, you may need to make your files readable. Do this by selecting all the
files in the folder Solar (use shift-click to select multiple files at
once), right-clicking on one of the selected files, choosing Properties
from the pop-up menu, then using the Read-only radio button to make all
the files writable.
Now double-click on the file with extension "dsw" (=
"Development Studio Workspace"). This starts the compiler. Ignore
error messages about not being able read Class Information and about some files could not
be opened. (The latter problem is that it is looking for some debug files my
computer!)
To compile and link the program, pick the Build Solar.exe
option from the Build menu. (Note that the Compile
option will compile, but not link the program.) The build can also be
invoked by a icon on the second menu bar, or by just pressing the F7
command key.
Hopefully, your compile and link worked without any error messages.
If there were error messages, you will need to fix something. One thing that
might have gone wrong is that you are using the dsw file from the Public
Folder, or you neglected to make your files readable (any error messages about not being
able to read files or about files being modified outside the editor could reflect these
problems).
Once the file Solar.exe is built, you can run it by
selecting Execute (or Go) from the Build
menu. Alternately you can use the Execute or Go
icon on the second menu bar, or you may just press F5. If all goes
well, the program will run correctly for you!
Modifying the program. Now lets try customizing the program.
First, open the file solar.c: On the left
window, select File View. Then find the file solar.c
in the file view, and double-click it, to open it for editting.
Second, find the line glColor3f(1.0,1.0,1.0); which
sets the color of the sun. Replace this by glColor3f(1.0,1.0,0.0 ). (The
last 1.0 changed to 0.0.)
Recompile and run the program. The sun should now be yellow.
Congratulations! You now know how to edit, compile and run OpenGL programs!
Using C++/OpenGL Help The C++ help information is fairly extensive. For example, try selecting Index from the Help menu. Then enter glColor3f, and see the associated documentation. Standard OpenGL commands are fairly well documented. The "aux" and "glut" commands are less well documented. For example, trying auxWireSphere in the Help-Index gives no information. However, under Help-Search, it gives several sample programs that use auxWireSphere.
Next task: Understand how Solar works,
especially how the ModelView matrix operations function. The first programing
assignment will involve modifying Solar.