CMSC 427 Computer Graphics Problem Set 0 - Prof. David Jacobs, Assignments of Computer Graphics

A problem set for a computer graphics course, cmsc 427. The problem set, assigned in january 2007, introduces opengl programming and requires students to modify a simple opengl program to add a control bar, accept keyboard input, make the rectangle move, and allow the user to drag the control bar with the mouse. The problem set also requires students to adjust the square's speed based on the control bar's position.

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-0pq
koofers-user-0pq 🇺🇸

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Problem Set 0
CMSC 427 – Computer Graphics
Assigned January 30, 2007
Due February 6, 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, by pressing the r (red), g
(green), or y (yellow) keys.
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 dragged by the
mouse. Make it so that the bar can be dragged vertically, but not horizontally.
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 have its upper left
corner at (500,103), and its lower right corner 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 moves
downward, the square slows down, while moving the bar back up speeds up the
square.
.

Partial preview of the text

Download CMSC 427 Computer Graphics Problem Set 0 - Prof. David Jacobs and more Assignments Computer Graphics in PDF only on Docsity!

Problem Set 0

CMSC 427 – Computer Graphics

Assigned January 30, 2007

Due February 6, 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, by pressing the r (red), g (green), or y (yellow) keys.
  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 dragged by the mouse. Make it so that the bar can be dragged vertically, but not horizontally. 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 have its upper left corner at (500,103), and its lower right corner 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 moves downward, the square slows down, while moving the bar back up speeds up the square. .