Feedback is similar to selection in that once you're in either mode, no pixels are produced and the screen is frozen. Instead of drawing occurring, information about primitives that would have been rendered is sent back to the application. The key difference between selection and feedback modes is what information is sent back. In selection mode, assigned names are returned to an array of integer values. In feedback mode, information about transformed primitives is sent back to an array of floating-point values. The values sent back to the feedback array consist of tokens that specify what type of primitive (point, line, polygon, image, or bitmap) has been processed and transformed, followed by vertex, color, or other data for that primitive. The values returned are fully transformed by lighting and viewing operations. Feedback mode is initiated by calling glRenderMode() with GL_FEEDBACK as the argument.
Here's how you enter and exit feedback mode:
Call glFeedbackBuffer() to specify the array to hold the feedback information. The arguments to this command describe what type of data and how much of it gets written into the array.
Call glRenderMode() with GL_FEEDBACK as the argument to enter feedback mode. (You can ignore the value returned by glRenderMode().) After this point, until you exit feedback mode, primitives aren't rasterized to produce pixels, and the contents of the framebuffer don't change.
Draw your primitives. As you issue drawing commands, you can make several calls to glPassThrough() to insert markers into the returned feedback data to help you parse it more easily.
Exit feedback mode by calling glRenderMode(), with GL_RENDER as the argument if you want to return to normal drawing mode. The integer value returned by glRenderMode() is the number of values stored in the feedback array.
Parse the data in the feedback array.
Establishes a buffer for the feedback data: buffer is a pointer to an array where the data is stored. The size argument indicates the maximum number of values that can be stored in the array. The type argument describes the information fed back for each vertex in the feedback array; its possible values and their meaning are shown in Table 12-1 . glFeedbackBuffer() must be called before feedback mode is entered. In the table, k is 1 in color-index mode and 4 in RGBA mode.
| Type Argument | Coordinates | Color | Texture | Total Values |
|---|---|---|---|---|
GL_2D | x, y | - | - | 2 |
GL_3D | x, y, z | - | - | 3 |
GL_3D_COLOR | x, y, z | k | - | 3 + k |
GL_3D_COLOR_TEXTURE | x, y, z | k | 4 | 7 + k |
GL_4D_COLOR_TEXTURE | x, y, z, w | k | 4 | 8 + k |
The Feedback Array
Using Markers in Feedback Mode
A Feedback Example
OpenGL Programming Guide