Math 155 - Geometry and Computer Graphics
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 Projects folder in the public directory (which is drive P:).  Make your own Projects folder in your personal disk space (in drive H:).    Copy the entire Solar folder from P:\Projects into your personal Projects folder.   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 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.  The moon is dark gray and may be hard to see.   You may use the up-arrow and down-arrow keys to control the speed of the solar system.  Experiment with the operation of this program.

    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. (This was a problem last year, but so far has not occured this year.)  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.
    To start the C++ compiler and load the Solar project, double-click on the file with extension "dsw" (= "Development Studio Workspace").  This starts the compiler. 
     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. 
    Then, 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.
    You may wish to make the moon brighter too.  For this, find the line glColor3f(0.3,0.3,0.3) that controls the color of the moon.   Replace this by glColor3f(0.5,0.5,0.5), to make it brighter.   Recompile and run the program.

    Congratulations!  You now know how to edit, compile and run OpenGL programs!

Using C/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 course homepage has links to online documentaion for OpenGL and for the glut extensions to OpenGL.

Next task:  Understand how Solar works, especially how the ModelView matrix operations function, as we cover the material in class.  The first programming assignments will involve modifying Solar.   The first assignment is a short assignment asking you to re-program the animation controls to work better.  In the second assignment, you will construct a more complicated solar system.