90 likes | 105 Views
Learn about key concepts in interactive 3-D computer graphics including viewing, hidden-surface removal, lighting, smooth animation, input devices, GUI programming, and the client-server model. Discover practical techniques for handling input and interaction in CG applications.
E N D
Introduction to Input/Interaction Glenn G. ChappellCHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 19, 2003
Review:Three Issues in 3-D CG • Viewing and Transformations • How do we look at a scene from any point of view within the scene, looking in any direction? • How do we do perspective projection? • How do we rotate things about arbitrary axes in 3-D? • Hidden-Surface Removal • When one object is behind another, we don’t want to see the hidden one. • Then there is transparency … • Lighting • 3-D CG is lousy without lighting. How do we do it? • In addition, we want to do smooth animation. CS 381
Review:Hidden-Surface Removal • Quick & Dirty Hidden-Surface Removal • Add GLUT_DEPTH to your glutInitDisplayMode call. • This allocates a depth buffer. • Remember, the various constants are bitwise-or’ed together. • Add GL_DEPTH_BUFFER_BIT to your glClear call. • This clears the depth buffer. • Again, bitwise-or. • Put glEnable(GL_DEPTH_TEST) somewhere in your initialization. • This enables hidden-surface removal. CS 381
Review:Double Buffering • Smooth Animation • Use double buffering. • Change GLUT_SINGLE to GLUT_DOUBLE in your glutInitDisplayMode call. • Change glFlush to glutSwapBuffers in your display callback. • Now the user only sees completed frames. • No flicker in animation. • Faster sometimes, slower others. • User cannot see the frame being built. • Sometimes this is bad, as with some complex fractals. CS 381
Input/Interaction:Overview • Our next topic is interactive GUI programming. • Input devices. • The client/server model. • … and how it facilitates various types of I/O. • Event-driven programming with the mouse. • Including “picking”. • Widgets. • Buttons, etc. CS 381
Input/Interaction:Input Devices & GUI’s • Modern GUI’s typically make strong assumptions about the I/O available to the user: • A keyboard and mouse (or other pointing device) are available. • The output is a (color?) raster display that can refresh the image in a fraction of a second. • As opposed to a printer, which typically has refresh times on the order of several seconds or more. • I/O is interactive, so that output is seen immediately by the user, who can respond with more input with little delay. • Input and output are tied together (so that the mouse position corresponds to a screen position, for example). CS 381
Input/Interaction:Client-Server Model [1/3] • Many operations in a computing environment, especially in a networked environment, are provided via a client-server model. • The server sits and waits for requests. • A client can request the server to provide services. • If the request is valid, the server provides the services to the client. • Example • A web server serves web pages to clients. • In this situation, the client is: the browser. CS 381
Input/Interaction:Client-Server Model [2/3] • The client-server model applies to CG as well. • We have a program that wants to create and display CG output on the user’s desktop machine. • Client: Application program. • Server: Graphics hardware. • This arrangement sometimes looks backwards (to me, anyway). CS 381
Input/Interaction:Client-Server Model [3/3] • The client-server model affects optimization. • Typically the greatest bottleneck is in the communication between the client and the server. • So we want to minimize such communication. • Thus we want to concentrate large operations on the client side or the server side. CS 381