1 / 14

Computer Graphics Input and Interaction

Computer Graphics Input and Interaction. Physical Input Devices :. Keyboard Device - used to input characters. Pointing Device - used to indicate locations on the screen. Pointing Devices :. ABSOLUTE POSITIONS from 2D grids of sensors: data tablets, light pens, touch sensitive screens.

wenda
Download Presentation

Computer Graphics Input and Interaction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer GraphicsInput and Interaction

  2. Physical Input Devices: Keyboard Device - used to input characters Pointing Device - used to indicate locations on the screen

  3. Pointing Devices: • ABSOLUTE POSITIONS from 2D grids of sensors: data tablets, light pens, touch sensitive screens • RELATIVE POSITIONSfrom movement of the balls: mice & trackballs • RELATIVE POSITIONSfrom velocities that are a function of position or pressure joysticks & spaceballs

  4. Logical Devices: a view of input from inside the application program • String - provides ASCII strings • Locator - provides position in world coordinates • Pick - returns identifier of an object • Choice - allows selection from several options • Dial - provides analog input • Stroke - returns an array of locations

  5. Logical Devices: a view of input from inside the application program • Measure - what the device returns to the user program • Trigger - physical input on the device used to signal the computer Example: Keyboard Input measure - the string of input characters trigger - the return or enter key

  6. Input Modes: a view of input from inside the application program • Request mode - measure is not returned until device is triggered • Sample mode - measure input is immediate when the appropriate function is called • Event mode - device trigger generates an event, event is placed in an event queue, event may be processed directly or a callback function may be specified to handle the event

  7. Using Pointing Devices: types of events • Move event - generated when mouse is moved while a button is depressed • Passive move event - generated when mouse is moved, but no button is depressed • Mouse event - occurs when any mouse button is depressed or released

  8. Using Pointing Devices: interacting with the mouse using GLUT glutMouseFunc(myMouseCallback); the mouse callback MUST HAVE THIS FORM void myMouseCallback(int button, int state, int x, int y) where button will have a value from this list GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON and state will have a value from this list GLUT_DOWN, GLUT_UP

  9. Using Pointing Devices: Example: code to exit when LMB pressed void myMouseCallback(int button, int state, int x, int y){ if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) exit(): }

  10. Using Pointing Devices: Example: draw square where LMB pressed,exit when LMB pressed void myMouseCallback(int button, int state, int x, int y){ if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) drawsquare(x, y); if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN) exit(); }

  11. WINDOW EVENTS: Two useful CALLBACKS in response to window events glutDisplayFunc(myDisplayCallback) Where myDisplayCallback() has no parameters. This function must handle all drawing (or object redefinition) commands. glutReshapeFunc(myReshapeCallback) Callback has the form myReshapeCallback(int w, int h) with w and h representing the new window size in pixels

  12. KEYBOARD EVENTS: The keyboard callback is registered with glutKeyboardFunc(myKeyboardCallback) Callback has the form myKeyboardCallback (unsigned char key, int x, int y) with key being the key depressed and (x,y) being the cursor position in window coordinates at the time the keyboard was triggered

  13. MENU EVENTS: We register a Menu Callback using int glutCreateMenu(menuCallback) Individual menu Entries (or options) are created by calls to glutAddMenuEntry("entry text", const) the first argument is the text that will appear on the menu entry, and the second argument is a unique integer constant value to be passed to the menuCallback when this menu entry is selected at runtime

  14. MENU EVENTS: The callback function has the form menuCallback (int id) the id value passed to this callback comes from the second argument toglutAddMenuEntry() finally, the menu is attached to a mouse button usingglutAttachMenu(GLUT_RIGHT_BUTTON)

More Related