gluTessCallback function

The gluTessCallback function defines a callback for a tessellation object.

Syntax

void WINAPI gluTessCallback(
   GLUtesselator *tess,
   GLenum        which,
   void (CALLBACK *fn)()
);

Parameters

tess

The tessellation object (created with gluNewTess).

which

The callback being defined. The following values are valid: GLU_TESS_BEGIN, GLU_TESS_BEGIN_DATA, GLU_TESS_EDGE_FLAG, GLU_TESS_EDGE_FLAG_DATA, GLU_TESS_VERTEX, GLU_TESS_VERTEX_DATA, GLU_TESS_END, GLU_TESS_END_DATA, GLU_TESS_COMBINE, GLU_TESS_COMBINE_DATA, GLU_TESS_ERROR, and GLU_TESS_ERROR_DATA.

For more information on these callbacks, see the following Remarks section.

fn

The function to be called.

Return value

This function does not return a value.

Remarks

Use gluTessCallback to specify a callback to be used by a tessellation object. If the specified callback is already defined, then it is replaced. If fn is NULL, then the existing callback becomes undefined.

The tessellation object uses these callbacks to describe how a polygon that you specify is broken into triangles.

There are two versions of each callback, one with polygon data that you can define and one without. If both versions of a particular callback are specified, the callback with the polygon data you specify will be used. The polygon_data parameter of gluTessBeginPolygon is a copy of the pointer that was specified when gluTessBeginPolygon was called.

The following are valid callbacks:

Callback Description
GLU_TESS_BEGIN The GLU_TESS_BEGIN callback is invoked like glBegin to indicate the start of a (triangle) primitive. The function takes a single argument of type GLenum. If you set the GLU_TESS_BOUNDARY_ONLY property to GL_FALSE, the argument is set to either GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, or GL_TRIANGLES. If you set the GLU_TESS_BOUNDARY_ONLY property to GL_TRUE, the argument is set to GL_LINE_LOOP. The function prototype for this callback is as follows: voidbegin (GLenumtype);
GLU_TESS_BEGIN_DATA GLU_TESS_BEGIN_DATA is the same as the GLU_TESS_BEGIN callback except that it takes an additional pointer argument. This pointer is identical to the opaque pointer provided when you call gluTessBeginPolygon. The function prototype for this callback is: voidbeginData (GLenumtype, void * polygon_data);
GLU_TESS_EDGE_FLAG The GLU_TESS_EDGE_FLAG callback is similar to glEdgeFlag. The function takes a single Boolean flag that indicates which edges lie on the polygon boundary. If the flag is GL_TRUE, then each vertex that follows begins an edge that lies on the polygon boundary; that is, an edge which separates an interior region from an exterior one. If the flag is GL_FALSE, then each vertex that follows begins an edge that lies in the polygon interior. The GLU_TESS_EDGE_FLAG callback (if defined) is invoked before the first vertex callback is made. Because triangle fans and triangle strips do not support edge flags, the begin callback is not called with GL_TRIANGLE_FAN or GL_TRIANGLE_STRIP if an edge flag callback is provided. Instead, the fans and strips are converted to independent triangles. The function prototype for this callback is:
voidedgeFlag (GLbooleanflag);
GLU_TESS_EDGE_FLAG_DATA The GLU_TESS_EDGE_FLAG_DATA callback is the same as the GLU_TESS_EDGE_FLAG callback except that it takes an additional pointer argument. This pointer is identical to the opaque pointer provided when you call gluTessBeginPolygon. The function prototype for this callback is: voidedgeFlagData (GLbooleanflag, void * polygon_data);
GLU_TESS_VERTEX The GLU_TESS_VERTEX callback is invoked between the begin and end callbacks. It is similar to glVertex , and it defines the vertexes of the triangles created by the tessellation process. The function takes a pointer as its only argument. This pointer is identical to the opaque pointer that you provided when you defined the vertex (see gluTessVertex). The function prototype for this callback is: voidvertex (void * vertex_data);
GLU_TESS_VERTEX_DATA The GLU_TESS_VERTEX_DATA is the same as the GLU_TESS_VERTEX callback except that it takes an additional pointer argument. This pointer is identical to the opaque pointer provided when you call gluTessBeginPolygon. The function prototype for this callback is: voidvertexData (void * vertex_data, void * polygon_data);
GLU_TESS_END The GLU_TESS_END callback serves the same purpose as glEnd. It indicates the end of a primitive, and it takes no arguments. The function prototype for this callback is: voidend (void);
GLU_TESS_END_DATA The GLU_TESS_END_DATA callback is the same as the GLU_TESS_END callback except that it takes an additional pointer argument. This pointer is identical to the opaque pointer provided when you call gluTessBeginPolygon. The function prototype for this callback is: voidendData (void * polygon_data);
GLU_TESS_COMBINE Call the GLU_TESS_COMBINE callback to create a new vertex when the tessellation detects an intersection, or to merge features. The function takes four arguments: An array of three elements, each of type Gldouble.
An array of four pointers.
An array of four elements, each of type GLfloat.
A pointer to a pointer.
The function prototype for this callback is:
voidcombine(GLdoublecoords[3], void * vertex_data[4], GLfloatweight[4], void **outData);
The vertex is defined as a linear combination of up to four existing vertexes, stored in vertex_data. The coefficients of the linear combination are given by weight; these weights always sum to 1.0. All vertex pointers are valid even when some of the weights are zero. The coords parameter gives the location of the new vertex.
Allocate another vertex, interpolate parameters using vertex_data and weight, and return the new vertex pointer in outData. This handle is supplied during rendering callbacks. Free the memory sometime after calling gluTessEndPolygon.
For example, if the polygon lies in an arbitrary plane in three-dimensional space, and you associate a color with each vertex, the GLU_TESS_COMBINE callback might look like the following:
void myCombine( GLdouble coords[3], VERTEX *d[4],                 GLfloat w[4], VERTEX **dataOut ) {     VERTEX *newVertex = new_vertex();     newVertex->x = coords[0];     newVertex->y = coords[1];     newVertex->z = coords[2];     newVertex->r = w[0]*d[0]->r + w[1]*d[1]->r + w[2]*d[2]->r +                    w[3]*d[3]->r;     newVertex->g = w[0]*d[0]->g + w[1]*d[1]->g + w[2]*d[2]->g +                    w[3]*d[3]->g;     newVertex->b = w[0]*d[0]->b + w[1]*d[1]->b + w[2]*d[2]->b +                    w[3]*d[3]->b;     newVertex->a = w[0]*d[0]->a + w[1]*d[1]->a + w[2]*d[2]->a +                    w[3]*d[3]->a;     *dataOut = newVertex; }
When the tessellation detects an intersection, the GLU_TESS_COMBINE or GLU_TESS_COMBINE_DATA callback (see below) must be defined, and must write a non-NULL pointer into dataOut. Otherwise the GLU_TESS_NEED_COMBINE_CALLBACK error occurs, and no output is generated. (This is the only error that can occur during tessellation and rendering.)
GLU_TESS_COMBINE_DATA The GLU_TESS_COMBINE_DATA callback is the same as the GLU_TESS_COMBINE callback except that it takes an additional pointer argument. This pointer is identical to the opaque pointer provided when you call gluTessBeginPolygon. The function prototype for this callback is: voidcombineData (GLdoublecoords[3], void *vertex_data[4], GLfloatweight[4], void **outData, void * polygon_data);
GLU_TESS_ERROR The GLU_TESS_ERROR callback is called when an error is encountered. The one argument is of type GLenum; it indicates the specific error that occurred and is set to one of the following: GLU_TESS_MISSING_BEGIN_POLYGON
GLU_TESS_MISSING_END_POLYGON
GLU_TESS_MISSING_BEGIN_CONTOUR
GLU_TESS_MISSING_END_CONTOUR
GLU_TESS_COORD_TOO_LARGE
GLU_TESS_NEED_COMBINE_CALLBACK
Call gluErrorString to retrieve character strings describing these errors. The function prototype for this callback is as follows:
voiderror (GLenumerrno);
The GLU library recovers from the first four errors by inserting the missing call or calls. GLU_TESS_COORD_TOO_LARGE indicates that some vertex coordinate exceeded the predefined constant GLU_TESS_MAX_COORD in absolute value, and that the value has been clamped. (Coordinate values must be small enough that two can be multiplied together without overflow.) GLU_TESS_NEED_COMBINE_CALLBACK indicates that the tessellation detected an intersection between two edges in the input data, and the GLU_TESS_COMBINE or GLU_TESS_COMBINE_DATA callback was not provided. No output will be generated.
GLU_TESS_ERROR_DATA The GLU_TESS_ERROR_DATA callback is the same as the GLU_TESS_ERROR callback, except that it takes an additional pointer argument. This pointer is identical to the opaque pointer provided when you call gluTessBeginPolygon. The function prototype for this callback is: voiderrorData (GLenumerrno, void * polygon_data);

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Glu.h
Library
Glu32.lib
DLL
Glu32.dll

See also

glBegin

glEdgeFlag

glEnd

glVertex

gluDeleteTess

gluErrorString

gluNewTess

gluTessBeginPolygon

gluTessEndPolygon

gluTessVertex