glFeedbackBuffer function

The glFeedbackBuffer function controls feedback mode.


void WINAPI glFeedbackBuffer(
   GLsizei size,
   GLenum  type,
   GLfloat *buffer



The maximum number of values that can be written into buffer.


A symbolic constant that describes the information that will be returned for each vertex. The following symbolic constants are accepted: GL_2D, GL_3D, GL_3D_COLOR, GL_3D_COLOR_TEXTURE, and GL_4D_COLOR_TEXTURE.


Returns the feedback data.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

Name Meaning
type was not an accepted value.
size was negative.
glFeedbackBuffer was called while the render mode was GL_FEEDBACK, or glRenderMode was called with argument GL_FEEDBACK before glFeedbackBuffer was called at least once.
The function was called between a call to glBegin and the corresponding call to glEnd.


The glFeedbackBuffer function controls feedback. Feedback, like selection, is an OpenGL mode. The mode is selected by calling glRenderMode with GL_FEEDBACK. When OpenGL is in feedback mode, no pixels are produced by rasterization. Instead, information about primitives that would have been rasterized is fed back to the application using OpenGL.

The glFeedbackBuffer function has three arguments:

  • buffer is a pointer to an array of floating-point values into which feedback information is placed.
  • size indicates the size of the array.
  • type is a symbolic constant describing the information that is fed back for each vertex.

You must issue glFeedbackBuffer before feedback mode is enabled (by calling glRenderMode with argument GL_FEEDBACK). Setting GL_FEEDBACK without establishing the feedback buffer, or calling glFeedbackBuffer while OpenGL is in feedback mode, is an error.

Take OpenGL out of feedback mode by calling glRenderMode with a parameter value other than GL_FEEDBACK. When you do this while OpenGL is in feedback mode, glRenderMode returns the number of entries placed in the feedback array. The returned value never exceeds size. If the feedback data required more room than was available in buffer, glRenderMode returns a negative value.

While in feedback mode, each primitive that would be rasterized generates a block of values that gets copied into the feedback array. If doing so would cause the number of entries to exceed the maximum, glFeedbackBuffer partially writes the block so as to fill the array (if there is any room left at all), and sets an overflow flag. Each block begins with a code indicating the primitive type, followed by values that describe the primitive's vertices and associated data. The glFeedbackBuffer function also writes entries for bitmaps and pixel rectangles. Feedback occurs after polygon culling and glPolygonMode interpretation of polygons has taken place, so polygons that are culled are not returned in the feedback buffer. It can also occur after polygons with more than three edges are broken up into triangles, if the OpenGL implementation renders polygons by performing this decomposition.

You can insert a marker into the feedback buffer with glPassThrough.

The following is the grammar for the blocks of values written into the feedback buffer. Each primitive is indicated with a unique identifying value followed by some number of vertices. Polygon entries include an integer value indicating how many vertices follow. A vertex is fed back as some number of floating-point values, as determined by type. Colors are fed back as four values in RGBA mode and one value in color-index mode.

feedbackList < feedbackItem feedbackList | feedbackItem

feedbackItem < point | lineSegment | polygon | bitmap | pixelRectangle | passThru

point < GL_POINT_TOKEN vertex

lineSegment < GL_LINE_TOKEN vertex vertex | GL_LINE_RESET_TOKEN vertex vertex

polygon < GL_POLYGON_TOKEN n polySpec

polySpec < polySpec vertex | vertex vertex vertex

bitmap < GL_BITMAP_TOKEN vertex

pixelRectangle < GL_DRAW_PIXEL_TOKEN vertex | GL_COPY_PIXEL_TOKEN vertex

passThru < GL_PASS_THROUGH_TOKEN value

vertex < 2d | 3d | 3dColor | 3dColorTexture | 4dColorTexture

2d < value value

3d < value value value

3dColor < value value value color

3dColorTexture < value value value color tex

4dColorTexture < value value value value color tex

color < rgba | index

rgba < value value value value

index < value

tex < value value value value

The value parameter is a floating-point number, and n is a floating-point integer giving the number of vertices in the polygon. The following are symbolic floating-point constants: GL_POINT_TOKEN, GL_LINE_TOKEN, GL_LINE_RESET_TOKEN, GL_POLYGON_TOKEN, GL_BITMAP_TOKEN, GL_DRAW_PIXEL_TOKEN, GL_COPY_PIXEL_TOKEN, and GL_PASS_THROUGH_TOKEN. GL_LINE_RESET_TOKEN is returned whenever the line stipple pattern is reset. The data returned as a vertex depends on the feedback type.

The following table gives the correspondence between type and the number of values per vertex; k is 1 in color-index mode and 4 in RGBA mode.

Type Coordinates Color Texture Total number of 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

Feedback vertex coordinates are in window coordinates, except w, which is in clip coordinates. Feedback colors are lighted, if lighting is enabled. Feedback texture coordinates are generated, if texture coordinate generation is enabled. They are always transformed by the texture matrix.

The glFeedbackBuffer function, when used in a display list, is not compiled into the display list but rather is executed immediately.

The following function retrieves information related to glFeedbackBuffer:

glGet with argument GL_RENDER_MODE


Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]

See also