Defines a callback for a tessellation object.
OpenGL C bindings library: libGL.a
void gluTessCallback(GLUtriangulatorObj *tobj, GLenum Which, void (*Function)())
The gluTessCallback subroutine defines a new callback for use by a tessellation object. If the specified callback is already defined, it is replaced. If the Function parameter is set to null, the existing callback is erased.
These callbacks are used by the tessellation object to describe how a polygon specified by the user is broken into triangles.
The acceptable callbacks are as follows:
GLU_TESS_BEGIN | The begin callback is invoked like glBegin to indicate the start of a
(triangle) primitive. The function takes a single argument of type
GLenum. If the GLU_TESS_BOUNDARY_ONLY property is set to
GL_FALSE, then the argument is set to either
GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, or
GL_TRIANGLES. If the
GLU_TESS_BOUNDARY_ONLY property is set to
GL_TRUE, then the argument will be set to
GL_LINE_LOOP. The function prototype for this callback is:
void begin(GLenum type); |
GLU_TESS_EDGE_FLAG | Similar to the glEdgeFlag subroutine. It takes a single
Boolean flag that indicates which edges of the created triangles were part o
f the original polygon defined by the user and which were created by the
tessellation process. If the flag is GL_TRUE, each vertex that follows
begins an edge that was part of the original polygon. If the flag is
GL_FALSE, each vertex that follows begins an edge that was generated
by the tessellator. To avoid confusion with the first few edges, the edge
flag callback is started before the first vertex callback is made.
Because triangle fans and strips do not support edge flags, the GLU_BEGIN callback cannot be called with GL_TRIANGLE_FAN or GL_TRIANGLE_STRIP if the GLU_EDGE_FLAG callback is provided. Instead, fans and strips are converted into independent triangles. The function prototype for this callback is: void edgeFlag(GLboolean flag); |
GLU_TESS_EDGE_FLAG_DATA | 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 gluTessBeginPolygon was
called. The function prototype for this callback is:
void edgeFlagData(GLboolean flag, void *polygon_data); |
GLU_TESS_VERTEX | Started between the GLU_BEGIN and GLU_END callbacks.
It is similar to the glVertex subroutine and defines the vertices of
the triangles created by the tessellation process. It takes a single pointer
as its only argument. This pointer is identical to the opaque pointer provided
by the user when the vertex was described. (See the
gluTessVertex
subroutine for details on specifying a polygon vertex.) The function prototype
for this callback is:
void vertex (void *vertex_data); |
GLU_TESS_END | Serves the same purpose as the glEnd subroutine and
indicates the end of a primitive. It takes no arguments.
The function prototype for this callback is:
void end(void); |
GLU_TESS_ERROR | Called when an error is encountered. The GLenum type is the
only argument and indicates the specific error that occurred. There are eight
errors unique to polygon tessellation. They are named GLU_TESS_ERROR1
through GLU_TESS_ERROR8. Character strings describing these errors
can be retrieved with the gluErrorString subroutine. The function
prototype for this callback is:
void error(GLenum errno); |
tobj | Specifies the tessellation object created with the gluNewTess subroutine. |
Which | Specifies the callback being defined. The following values are valid: |
Function | Specifies the new callback. |
Tessellated polygons can be rendered directly as in the following example:
gluTessCallback(tobj, GLU_TESS_BEGIN, glBegin); gluTessCallback(tobj, GLU_TESS_VERTEX, glVertex3dv); gluTessCallback(tobj, GLU_TESS_END, glEnd); gluBeginPolygon(tobj); gluTessVertex(tobj, v, v); ... gluEndPolygon(tobj);
Typically, the tessellated polygon should be stored in a display list so that is does need to be retessellated every time it is rendered.
/usr/include/GL/gl.h | Contains C language constraints, variable type definitions, and ANSI function prototypes for OpenGL. |
The glBegin subroutine, glEdgeFlag subroutine, glVertex subroutine, gluDeleteTess subroutine, gluErrorString subroutine, gluNewTess subroutine, gluTessVertex subroutine, gluErrorString subroutine.