LAB 2 -October 18th, 2011
NOTE: If you are working on the new machines, there may be issues with driver support,
leading to a crash at run-time. Please download up to date drivers from:
(Please ask Rowan if you are unsure what to do).
The GLUT files are now installed, so you will build your program a bit differently this week. For this lab, you will again need to create a Visual C++ project for a GLUT application as follows:
- launch Microsoft Visual Studio 2008
- click File -> New Project
- choose Visual C++ Projects -> Win32 in the project type chooser
- choose Win32 Console Project in the template shooser
- enter a name for your new project and choose the directory where to
- This will create a directory named as your project, with default files in
- A cpp file named as your project contains the default main function, you
can see it in the solution explorer on the right.
- Replace it with the source file provided here
- To do this,
- right click on the file in the solution explorer and select
- copy the file in http://isg.cs.tcd.ie/cosulliv/Graphics/Labs/Lab2/ into your project directory (using windows explorer)
- right click on the project name in the solution explorer and select Add -> Existing Item
- select the file you want to add to the project and click Add
- Generally, this is how you will add pre-existing source files to your
The glut library has now been installed in the system directories, so all you have to do is...
Before building your project, go in Project -> Properties
- go to main.cpp and remove the lines #include <gl/glut.h> and #include <gl/glu.h> and add the line #include <glut.h>
Change the scene to depict a hierarchical object - something like this:
- select Configuration Properties -> C/C++ -> Precompiled Headers
- change the setting from Use Precompiled Header to Not Using (an unfolding
choice appears when you click on the field)
- To build, click Build -> Build project name
Play around with the material properties to change the colours to whatever you like for the sub-parts.
The cylinder and sphere should rotate with respect to the cube,
and the cylinder and sphere "Arm" sould also be rotating around the cube's z-axis,
thus pivoting around the cylinder's base, i.e., it should look something like this:
Now, make the object move in some interesting way... e.g., translate it from one side of the screen to the other as it's rotating, e.g.:
Finally, turn the hierarchy into a "one-to-many" one, e.g., give the cube 2 or more independently moving "arms" instead of one.