4ICT10 Computer Graphics and Virtual Reality 5. Input Devices Introduction to OpenGL Dr Ann McNamara Graphics Input Primitives • String • Choice/Selection • Valuator • Locator – coordinate pair x,y • Pick required for interactive graphics 1 Input Devices • There are hundreds of input devices • Keyboard most familiar input device • Early computers communicated one bit at a time • Users had to flip switches or plug wires into switchboards to enter data Keyboard • Types characters on screen at point identified by cursor • Some keys have special functions – Cursor (arrow) keys – Delete key – Enter key – Function keys (f-keys) • QWERTY keyboard standard 2 Pointing devices • Pointing devices are inadequate for input text and numbers into computers. They are usually used with keyboards. • Mouse – Sends commands – Points around screen • Trackball – Upside down mouse Pointing devices • Touch pad – Small panel – Track point – Small joystick – IBM ThinkPad and other laptops • Joystick – Like arcade games • Graphics tablets – Used by artists and designers • Touch Screens – Common in kiosks 3 Scanners • A 2D scanner converts photographs, drawings, charts and other printed information into bit patterns that can be stored and manipulated in a computer's memory. • 3D Scanners 4 3D Scanners Colortron 5 Digital Cameras • Convert real world to digital, like scanners • Not limited to two dimensional objects Motion Capture 6 4ICT10 Computer Graphics and Virtual Reality Getting Started with OpenGL Requirements • An environment that lets us – write programs – execute programs • Hardware to display (screen) • Library of software tools to perform drawing of graphics primitives. 7 Device Independent Programming • Same program can be compiled and run on a variety of graphics environments. • API (Application Programmer Interface) – a collection of routines – a model of how the routines work Event Driven Programming • Windows based systems are event driven – mouse click, key press, resize window • System automatically handles an event queue • CallbackFunction • OpenGL comes with a Utility Toolkit – glutMouseFunc(mymouse) registers the function mymouse() as the function executed when mouse events occur. 8 OpenGL® • OpenGL is a software interface to a graphics system implemented in hardware or software. • It is theoretically device independent. • OpenGL uses a client-server model, where client and server need not reside on the same machine. • Default language is C/C++. • The actual drawing operations are performed by the underlying windows system or accelerated graphics hardware (where available, e.g. 3Dfx, PowerVR, Intergraph, Silicon Graphics). OpenGL® • Programmer’s model: 9 OpenGL® • OpenGL is interactive and dynamic and therefore we (cid:222) must handle interaction from the user event driven model • The GL library is the core OpenGL system: – modeling, viewing, lighting, clipping • The GLU library (GL Utility) simplifies common tasks: – creation of common objects (e.g. spheres, quadrics) – specification of standard views (e.g. perspective, orthographic) • The GLUT library (GL Utility Toolkit) provides the interface with the windowing system. – window management, menus, mouse interaction Skeleton Program void main() { initialise things create a screen window glutDisplayFunc(myDisplay); glutReshapeFunc(myReshape); glutMouseFunc(myMouse); glutKeyboardFunc(myKeyboard); perhaps initialise other things glutMainLoop(); } define all callback functions 10
Description: