Export (0) Print
Expand All

Specifying Callbacks

You can specify up to five callback functions for a tessellation. Any functions that you do not specify are not called during the tessellation, and you do not get any information they might have returned. You specify the callback functions with gluTessCallback.

The gluTessCallback function associates the callback function fn with the tessellation object tessobj. The type of the callback is determined by the parameter type, which can be GLU_BEGIN, GLU_EDGE_FLAG, GLU_VERTEX, GLU_END, or GLU_ERROR. The five possible callback functions have the following prototypes.

Callback functionPrototype
GLU_BEGINvoid begin(GLenumtype );
GLU_EDGE_FLAGvoid edgeFlag(GLbooleanflag );
GLU_VERTEXvoid vertex(void *data );
GLU_ENDvoid end( void );
GLU_ERRORvoid error(GLenumerrno );

 

To change a callback function, call gluTessCallback with the new function. To eliminate a callback function without replacing it with a new one, pass gluTessCallback a null pointer for the appropriate function.

As tessellation proceeds, the callback functions are called in a manner similar to the way you would use the OpenGL functions glBegin, glEdgeFlag, glVertex, and glEnd.

The GLU_BEGIN callback function is invoked with one of three possible parameters:

  • GL_TRIANGLE_FAN
  • GL_TRIANGLE_STRIP
  • GL_TRIANGLES

After calling the GLU_BEGIN callback function, and before calling the callback function associated with GLU_END, some combination of the GLU_EDGE_FLAG and GLU_VERTEX callbacks is invoked. The associated vertices and edge flags are interpreted exactly as they are in OpenGL between glBegin(GL_TRIANGLE_FAN), glBegin(GL_TRIANGLE_STRIP), or glBegin(GL_TRIANGLES) and the matching glEnd.

Because edge flags make no sense in a triangle fan or triangle strip, if there is a callback function associated with GLU_EDGE_FLAG, the GLU_BEGIN callback is called only with GL_TRIANGLES. The GLU_EDGE_FLAG callback function works analogously to the OpenGL glEdgeFlag function.

If there is an error during the tessellation, the error callback function is invoked. The error callback function is passed a GLU error number. You can obtain a character string describing the error with the gluErrorString function.

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft