Name
nurb:Callback -- define a callback for a NURBS object
Synopsis
nurb:Callback(which, func)
Function
nurb:Callback() is used to define a callback to be used by a NURBS object. If the specified callback is already defined, then it is replaced. If func is Nil, then this callback will not get invoked and the related data, if any, will be lost.

Except the error callback, these callbacks are used by NURBS tessellator (when #GLU_NURBS_MODE is set to be #GLU_NURBS_TESSELLATOR) to return back the OpenGL polygon primitives resulting from the tessellation. The error callback function is effective no matter which value that #GLU_NURBS_MODE is set to. All other callback functions are effective only when #GLU_NURBS_MODE is set to #GLU_NURBS_TESSELLATOR.

All callbacks receive a handle to the NURBS object as their first parameter. The second parameter depends on the callback type specified in which.

The legal callbacks are as follows:

#GLU_NURBS_BEGIN
The begin callback indicates the start of a primitive. The function receives an integer argument, which can be one of #GLU_LINES, #GLU_LINE_STRIP, #GLU_TRIANGLE_FAN, #GLU_TRIANGLE_STRIP, #GLU_TRIANGLES, or #GLU_QUAD_STRIP. The default begin callback function is Nil.

#GLU_NURBS_VERTEX
The vertex callback indicates a vertex of the primitive. The coordinates of the vertex are passed in a table parameter as four floating-point values. All the generated vertices have dimension 3; that is, homogeneous coordinates have been transformed into affine coordinates. The default vertex callback function is Nil.

#GLU_NURBS_NORMAL
The normal callback is invoked as the vertex normal is generated. The components of the normal are passed in a table parameter as three floating-point values. In the case of a NURBS curve, the callback function is effective only when the user provides a normal map (#GLU_MAP1_NORMAL). In the case of a NURBS surface, if a normal map (#GLU_MAP2_NORMAL) is provided, then the generated normal is computed from the normal map. If a normal map is not provided, then a surface normal is computed in a manner similar to that described for evaluators when #GLU_AUTO_NORMAL is enabled. The default normal callback function is Nil.

#GLU_NURBS_COLOR
The color callback is invoked as the color of a vertex is generated. The components of the color are passed in a table parameter. This callback is effective only when the user provides a color map (#GLU_MAP1_COLOR_4 or #GLU_MAP2_COLOR_4). The table passed to this callback contains four floating-point components: R, G, B, A. The default color callback function is Nil.

#GLU_NURBS_TEXTURE_COORD
The texture callback is invoked as the texture coordinates of a vertex are generated. These coordinates are passed in a table parameter. The number of texture coordinates can be 1, 2, 3, or 4 depending on which type of texture map is specified (#GLU_MAP1_TEXTURE_COORD_1, #GLU_MAP1_TEXTURE_COORD_2, #GLU_MAP1_TEXTURE_COORD_3, #GLU_MAP1_TEXTURE_COORD_4, #GLU_MAP2_TEXTURE_COORD_1, #GLU_MAP2_TEXTURE_COORD_2, #GLU_MAP2_TEXTURE_COORD_3, #GLU_MAP2_TEXTURE_COORD_4). If no texture map is specified, this callback function will not be called. The default texture callback function is Nil.

#GLU_NURBS_END
The end callback is invoked at the end of a primitive. The default end callback function is Nil. This callback doesn't receive any parameters except a handle to the NURBS object.

Please consult an OpenGL reference manual for more information.

Inputs
which
specifies the callback being defined (see above)
func
specifies the function that the callback calls

Show TOC