![]() ![]() Thus, when the list of names is returned, you can use it to determine which primitives might have been selected on the screen by the user. ![]() You construct the name stack by loading names onto it as you issue primitive drawing commands while in selection mode. The list of primitives is actually returned as an array of integer-valued names and related data - the hit records - that correspond to the current contents of the name stack. When you exit selection mode, OpenGL returns a list of the primitives that intersect the viewing volume (remember that the viewing volume is defined by the current modelview and projection matrices and any additional clipping planes, as explained in Chapter 3.) Each primitive that intersects the viewing volume causes a selection hit. However, once you're in selection mode, the contents of the framebuffer don't change until you exit selection mode. Typically, when you're planning to use OpenGL's selection mechanism, you first draw your scene into the framebuffer, and then you enter selection mode and redraw the scene. ![]() "Feedback" describes how to obtain information about what would be drawn on the screen and how that information is formatted."Selection" discusses how to use selection mode and related routines to allow a user of your application to pick an object drawn on the screen.This chapter explains each of these modes in its own section: In these modes, the contents of the color, depth, stencil, and accumulation buffers are not affected. Thus, the screen remains frozen - no drawing occurs - while OpenGL is in selection or feedback mode. ![]() In both selection and feedback modes, drawing information is returned to the application rather than being sent to the framebuffer, as it is in rendering mode. For example, if you want to draw three-dimensional objects on a plotter rather than the screen, you would draw the items in feedback mode, collect the drawing instructions, and then convert them to commands the plotter can understand. Instead of using the calculated results to draw an image on the screen, however, OpenGL returns (or feeds back) the drawing information to you. In feedback mode, you use your graphics hardware and OpenGL to perform the usual rendering calculations. Selection is actually a mode of operation for OpenGL feedback is another such mode. You can use this mechanism together with a special utility routine to determine which object within the region the user is specifying, or picking, with the cursor. To help you, OpenGL provides a selection mechanism that automatically tells you which objects are drawn inside a specified region of the window. Since objects drawn on the screen typically undergo multiple rotations, translations, and perspective transformations, it can be difficult for you to determine which object a user is selecting in a three-dimensional scene. OpenGL is designed to support exactly such interactive applications. Other applications allow the user to identify objects on the screen and then to move, modify, delete, or otherwise manipulate those objects. Some graphics applications simply draw static images of two- and three-dimensional objects. Use the OpenGL feedback mode to obtain the results of rendering calculations.Create applications that allow the user to select a region of the screen or pick an object drawn on the screen.After reading this chapter, you'll be able to do the following: ![]()
0 Comments
Leave a Reply. |