This assignment is about using nested, hierarchical models in OpenGL.
This assignment is due Monday, March 18.
Download this zip file. In the zip file you will find a skeleton OpenGL program called problem1.c . Complete this program so that it draws six "bricks", each of a different color, that are stacked on top of each other as shown in the following image. The user can click on a brick and move it horizontally. As a brick moves, the bricks on top of it move with it. When a brick hits a brick next to it, or the edge of the brick below it, or the edge of the window, the brick cannot be moved any more in that direction.
When a user clicks on a brick, there is a trick to make it easy to figure out which brick they clicked on. (The hard way is to convert the mouse pointer coordinates into world coordinates and then try to figure out, in world coordinates, which brick contains the mouse pointer,) The easy way is to ask OpenGL for the color of the pixel that the mouse clicked on. Since every brick has a different color, knowing the color of the pixel determines which brick was chosen. You ask OpenGL for the color of a pixel by using the glReadPixels() function. There is a demonstration program in the zip file showing you how to use this function. Here is the function's documentation.
glReadPixels()
Turn in a zip file called CS455Hw4Surname.zip containing your version of the program problem1.c . Please remember to put your name inside of your source file.
This assignment is due Monday, March 18.
|