Docsity

Problems Set - Computer Graphics - Assignment | CMSC 427, Assignments of Computer Graphics

Toggle sidebar
bg1
Problem Set 0
CMSC 427 – Computer Graphics
Assigned September 4, 2007
Due September 11, 2007
This problem set will introduce OpenGL programming. You will start with a simple,
working OpenGL program and modify it. The source code for this problem is available
from the class web page, along with an executable, showing what the final result should
look like. You don’t have to make yours exactly the same (ie., the colors and sizes of
things can vary) but produce the same functionality.
1. 15 points. Enhance the program to place a control bar (ie, just a rectangle) on the
right side, starting in the upper right-hand corner.
2. 15 points. Now modify your program to accept keyboard input. Your program
should allow the user to change the color of the square or the bar by pressing the r
(red), g (green), or y (yellow) keys. If you press one of these keys while the
mouse is on the left side of the screen, the square should change color. If the
mouse is on the right side of the screen, the bar should change color.
3. 15 points. Next, make the rectangle move. The rectangle should move downward
at a constant speed. When it reaches the bottom of the screen, it starts over again
at the top. This can be done using either glutTimerFunc or glutIdleFunc.
4. 40 points. Now we will modify the program to allow more continuous user input
so that the user can adjust the control bar. Modify your program so that if the user
left clicks the mouse while the mouse is on top of the bar, and then holds the
mouse button down and drags the mouse, then the bar will be resized by the
mouse. Make it so that the bar can change its height, but not its width.
a. For example, suppose the bar has it’s upper left corner at (500,0), and its
lower right corner at (600,20). The user clicks the left mouse button while
the mouse is at position (542, 17). The user keeps the left button down,
and moves the mouse to position (560, 103), and then releases the mouse
button. When this is finished, the bar should now still have its upper left
corner at (500,0), but now ts lower right corner is at (600, 123). As the
mouse is moving, the bar should move continuously with the mouse.
b. On the other hand, if the user clicks the left mouse button with the mouse
in position (7,13), and then drags the mouse, the bar should not move.
5. 15 points. Finally, modify the speed of the square, so that as the bar becomes
large the square speeds up.
.

Partial preview of the text

Download Problems Set - Computer Graphics - Assignment | CMSC 427 and more Assignments Computer Graphics in PDF only on Docsity!

Problem Set 0

CMSC 427 – Computer Graphics

Assigned September 4, 2007

Due September 11, 2007

This problem set will introduce OpenGL programming. You will start with a simple, working OpenGL program and modify it. The source code for this problem is available from the class web page, along with an executable, showing what the final result should look like. You don’t have to make yours exactly the same (ie., the colors and sizes of things can vary) but produce the same functionality.

  1. 15 points. Enhance the program to place a control bar (ie, just a rectangle) on the right side, starting in the upper right-hand corner.
  2. 15 points. Now modify your program to accept keyboard input. Your program should allow the user to change the color of the square or the bar by pressing the r (red), g (green), or y (yellow) keys. If you press one of these keys while the mouse is on the left side of the screen, the square should change color. If the mouse is on the right side of the screen, the bar should change color.
  3. 15 points. Next, make the rectangle move. The rectangle should move downward at a constant speed. When it reaches the bottom of the screen, it starts over again at the top. This can be done using either glutTimerFunc or glutIdleFunc.
  4. 40 points. Now we will modify the program to allow more continuous user input so that the user can adjust the control bar. Modify your program so that if the user left clicks the mouse while the mouse is on top of the bar, and then holds the mouse button down and drags the mouse, then the bar will be resized by the mouse. Make it so that the bar can change its height, but not its width. a. For example, suppose the bar has it’s upper left corner at (500,0), and its lower right corner at (600,20). The user clicks the left mouse button while the mouse is at position (542, 17). The user keeps the left button down, and moves the mouse to position (560, 103), and then releases the mouse button. When this is finished, the bar should now still have its upper left corner at (500,0), but now ts lower right corner is at (600, 123). As the mouse is moving, the bar should move continuously with the mouse. b. On the other hand, if the user clicks the left mouse button with the mouse in position (7,13), and then drags the mouse, the bar should not move.
  5. 15 points. Finally, modify the speed of the square, so that as the bar becomes large the square speeds up. .