Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.

Similar presentations


Presentation on theme: "Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College."— Presentation transcript:

1 Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource

2 Events and Interactive Programming Giving the user the ability to manipulate the scene and image

3 Interaction is Important in Computer Graphics It can give the user control of parts of the images you create It can give the user control of some of the processes that go into the images It is the basis of the interfaces that you can add to your programs

4 Interaction in OpenGL is Based on Events An event is a change in the control state of a computer system This definition is very general, but it includes all the events needed for graphics Events come from devices, from programs, and from the system itself

5 Event Handling Events cause event records to be posted to the event queue The system removes event records from the queue and takes actions Many event actions are done via callback functions

6 Events for Graphics Keypress events –Keyboard –Special Menu events Mouse events –Mouse motion –Mouse buttons Software events System events Window events

7 Meanings of Interaction Keyboards –Discrete input –Key choice can have semantic meaning Identify object or action Mouse –Position identifies points spatially –Motion is continuous Can identify continuous motion or selection from continuous choices

8 Object Selection This is an important activity in graphics The user selects an object by selecting a point on the screen You must then identify the object that corresponds to that point The point gives you a line in eye space, and you could calculate all intersections: could be difficult!

9 Object Selection (2) You could keep the question in screen space by identifying the pixel chosen Then as the scene is drawn, you could keep track of any object that uses that pixel and the depth of that pixel Finally you could identify the correct object from those by using the depth value Not so difficult with system support

10 Events and the Scene Graph The scene graph, to now, has defined a scene statically However, it is not difficult to let any part of the scene graph vary Events could be used to identify the part of the scene graph and how it is to change –Change geometry, change transformations, change appearance

11 Interaction and Visual Communication The main reason we make images is to communicate with our audience Interaction offers rich choices for communication –Changing the view –Changing the scene Critical that the way we create the interaction is consistent with the way the audience thinks of the action

12 Events in OpenGL Idle Display Reshape Keyboard Special Menu Mouse active motion Mouse passive motion Timer

13 Selection in OpenGL Selections operate by creating hit records in the selection buffer One entry in the record for each object that uses the selected pixel Draw in selection mode instead of render mode Process the record to identify the selection

14 Selection in OpenGL (2) There are some clever tricks you can use to make selection work better Modify the scene you will draw in selection mode –Only draw things that can be selected –Draw simplified versions of these things –Can even draw invisible controls!

15 Selection in OpenGL (3) There is a completely different approach using the back buffer –Draw everything that can be selected –Use simplified versions –Draw each object in a unique color –Look at the selected pixel in the final back buffer –The color of the pixel will tell you what object is nearest the viewer; this is usually the one you want

16 User Interaction Toolkits There are many toolkits that have been built on top of OpenGL They let you create widgets -- buttons, text boxes, sliders, dials, … that the user can manipulate They usually operate by letting you create a separate window where you lay out the controls

17 MUI MUI is a particular user interaction toolkit It’s very simple, but very easy to use This figure shows the look of a MUI control panel

18 MUI (2) An example of a simple MUI application


Download ppt "Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College."

Similar presentations


Ads by Google