Homework 2

Create an interactive drawing program.

When a mouse button is pressed, or the mouse is moved with the button pressed, draw something at the location of the mouse. Preferably, a continuous stroke should be drawn as the mouse moves.

Allow the user to change the color being drawn. A minimal interface would be: hit "r" key to draw in red, "g" to draw in green, "b" to draw in blue.

Due: in class, Thursday, September 18.




Interaction






Historical Highlights

Vannevar Bush - MEMEX
Ivan Sutherland - Sketchpad
MIT - Spacewar
Ivan Sutherland - Ultimate Display
Douglas Engelbart - NLS (oNLine System)
Xerox PARC - Star





Some Types of Devices






Common Devices






Reading Devices

Polling

Event driven






Feedback

Change in response to users' actions

Lets users know that they're interacting

Immediate, simple response often useful

Can be visual, auditory, haptic






Latency

Delay between an action and its result

Humans very aware of latency > ~ 100 milliseconds

Many delays inherent in different stages of hardware/software
"End-to-end" latency = total delay

Long latency slows up user
Irregular latency even worse


Latency is distinct from update speed






Resolution

Measure of how many distinct values a device can report


On/off switch = 1 bit resolution


"Non-analog" joystick = 3 values (+1, 0, -1) for X and for Y

8 bit resolution joystick = 256 possible values for X and for Y

16 bit resolution joystick = 65536 possible values for X and for Y






Noise

Signal = the information we want to communicate to the computer (e.g. button state, pointer position)

Noise = variations in the signal, outside of our control

Examples:

Applications may need to allow for noise in input data






Fitts' Law

From human movement research - Paul Fitts, 1954

Predicts time needed to move from a starting position to a target - e.g. to point at something

D = distance to target
W = width of target











GLUT






GLUT Keyboard Functions

glutKeyboardFunc(func) Called when a 'character' key is hit
glutSpecialFunc(func) Called when a 'special' key is hit
glutKeyboardUpFunc(func) Called when a 'character' key is released
glutSpecialUpFunc(func) Called when a 'special' key is released
glutGetModifiers() Returns state of shift, control, alt keys when event happened
glutIgnoreKeyRepeat(val) Tells GLUT whether to ignore automatic keyboard repeat





GLUT Keyboard Callback

All keyboard callback functions take the form:

    def func(key, x, y):
         ...

key is the key pressed or released - either a single-character string (e.g. 'a'), or a special-key constant (e.g. GLUT_KEY_UP)

x, y is the mouse pointer location when the key event occurred







GLUT Mouse Functions

glutMouseFunc(func) Called when a mouse button is pressed
glutMotionFunc(func) Called when mouse moves, while button pressed
glutPassiveMotionFunc(func) Called when mouse moves, with no button pressed
glutGetModifiers() Returns state of shift, control, alt keys when event happened





GLUT Mouse Callback

Mouse-button callback functions take the form:

    def func(button, state, x, y):
         ...

button is the button pressed or released - one of GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON

state is GLUT_DOWN if the button was pressed, or GLUT_UP if it was released

x, y is the mouse pointer location when the button was pressed or released






GLUT Motion Callback

Mouse-motion callback functions take the form:

    def func(x, y):
         ...

x, y is the new mouse pointer location






Window Coordinates

Mouse positions are given in window coordinates

Measured in pixels, from the upper left corner



Creative Commons License
This document is by Dave Pape, and is released under a Creative Commons License.