GLUNURBSCALLBACK(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’… NAME πŸ’…

gluNurbsCallback β€” bestie, this is the one that lets you define a callback for a NURBS object πŸ¦‹

(Yeah, we're in section 3G, the GLU corner of the manual. Come sit with me.)


✨ C SPECIFICATION ✨

void gluNurbsCallback( GLUnurbs* nurb,
                       GLenum which,
                       _GLUfuncptr CallBackFunc )

πŸŽ€ PARAMETERS πŸŽ€

  • nurb β€” the NURBS object in question, aka the one you made with gluNewNurbsRenderer. It's your baby. πŸ’–
  • which β€” which callback you're defining rn. The valid values are GLU_NURBS_BEGIN, GLU_NURBS_VERTEX, GLU_NURBS_NORMAL, GLU_NURBS_COLOR, GLU_NURBS_TEXTURE_COORD, GLU_NURBS_END, GLU_NURBS_BEGIN_DATA, GLU_NURBS_VERTEX_DATA, GLU_NURBS_NORMAL_DATA, GLU_NURBS_COLOR_DATA, GLU_NURBS_TEXTURE_COORD_DATA, GLU_NURBS_END_DATA, and GLU_NURBS_ERROR. That's the whole roster, no more no less. πŸ‘‘
  • CallBackFunc β€” the function your callback calls. The actual function. The main character. ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so gluNurbsCallback defines a callback for a NURBS object. If the callback you're specifying is already defined, it just gets replaced β€” no drama, no error, just swap. And if CallBackFunc is NULL? Then that callback simply won't get invoked, and the related data, if there is any, will be lost. Gone. Poof. So like, don't do that unless you mean it. πŸ’€

Except for the error callback, these callbacks get used by the NURBS tessellator (that's when GLU_NURBS_MODE is set to GLU_NURBS_TESSELLATOR) to hand you back the OpenGL polygon primitives that came out of the tessellation. And here's the tea: there are two versions of every callback β€” one with a user data pointer and one without. If you specify both versions for a particular callback, then the one with the user data pointer wins. No tiebreakers, that's just the rule. Also note that userData is a copy of the pointer that was specified at the last call to gluNurbsCallbackData. Copy. Not the same pointer object, a copy of it. iykyk. 🫢

The error callback function works no matter which value GLU_NURBS_MODE is set to. Every other callback function is only effective when GLU_NURBS_MODE is set to GLU_NURBS_TESSELLATOR. Periodt.

The legal callbacks, one by one, bestie:

🌸 GLU_NURBS_BEGIN

The begin callback signals the start of a primitive. It takes a single argument of type GLenum, which can be one of GL_LINES, GL_LINE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, GL_TRIANGLES, or GL_QUAD_STRIP. The default begin callback function is NULL. The prototype looks like:

void begin ( GLenum type );

🌸 GLU_NURBS_BEGIN_DATA

Same as the GLU_NURBS_BEGIN callback, except it takes an additional pointer argument. That pointer is a copy of the pointer specified at the last call to gluNurbsCallbackData. Default is NULL. Prototype:

void beginData (GLenum type, void *userData);

🌸 GLU_NURBS_VERTEX

The vertex callback signals a vertex of the primitive. The vertex coordinates live in the parameter vertex. And heads up: all the generated vertices have dimension 3 β€” meaning the homogeneous coordinates have already been transformed into affine coordinates. Default is NULL. Prototype:

void vertex ( GLfloat *vertex );

🌸 GLU_NURBS_VERTEX_DATA

Same as the GLU_NURBS_VERTEX callback, but with an extra pointer argument β€” a copy of the pointer specified at the last call to gluNurbsCallbackData. Default is NULL. Prototype:

void vertexData ( GLfloat *vertex, void *userData );

🌸 GLU_NURBS_NORMAL

The normal callback fires as the vertex normal gets generated. The normal's components live in the parameter normal. For a NURBS curve, this callback is only effective when the user provides a normal map (GL_MAP1_NORMAL). For a NURBS surface, if a normal map (GL_MAP2_NORMAL) is provided, the generated normal is computed from that normal map; if no normal map is provided, then a surface normal gets computed in a manner similar to what's described for evaluators when GL_AUTO_NORMAL is enabled. Default is NULL. Prototype:

void normal ( GLfloat *normal );

🌸 GLU_NURBS_NORMAL_DATA

Same as GLU_NURBS_NORMAL, plus an additional pointer argument β€” a copy of the pointer from the last call to gluNurbsCallbackData. Default is NULL. Prototype:

void normalData ( GLfloat *normal, void *userData );

🌸 GLU_NURBS_COLOR

The color callback fires as a vertex's color is generated. The color components live in the parameter color. This one is only effective when the user provides a color map (GL_MAP1_COLOR_4 or GL_MAP2_COLOR_4). And color holds four components: R,G,B,A. Default is NULL. Prototype:

void color ( GLfloat *color );

🌸 GLU_NURBS_COLOR_DATA

Same as GLU_NURBS_COLOR, plus an additional pointer argument β€” a copy of the pointer from the last call to gluNurbsCallbackData. Default is NULL. Prototype:

void colorData ( GLfloat *color, void *userData );

🌸 GLU_NURBS_TEXTURE_COORD

The texture callback fires as the texture coordinates of a vertex are generated. They live in the parameter texCoord. The number of texture coordinates can be 1, 2, 3, or 4, depending on which type of texture map is specified (GL_MAP1_TEXTURE_COORD_1, GL_MAP1_TEXTURE_COORD_2, GL_MAP1_TEXTURE_COORD_3, GL_MAP1_TEXTURE_COORD_4, GL_MAP2_TEXTURE_COORD_1, GL_MAP2_TEXTURE_COORD_2, GL_MAP2_TEXTURE_COORD_3, GL_MAP2_TEXTURE_COORD_4). If no texture map is specified, this callback function will not be called. At all. Not once. Default is NULL. Prototype:

void texCoord ( GLfloat *texCoord );

🌸 GLU_NURBS_TEXTURE_COORD_DATA

Same as GLU_NURBS_TEXTURE_COORD, plus an additional pointer argument β€” a copy of the pointer from the last call to gluNurbsCallbackData. Default is NULL. Prototype:

void texCoordData (GLfloat *texCoord, void *userData);

🌸 GLU_NURBS_END

The end callback fires at the end of a primitive. Default is NULL. Prototype:

void end ( void );

🌸 GLU_NURBS_END_DATA

Same as GLU_NURBS_END, plus an additional pointer argument β€” a copy of the pointer from the last call to gluNurbsCallbackData. Default is NULL. Prototype:

void endData ( void  *userData );

🌸 GLU_NURBS_ERROR

The error function is called when an error is encountered. Its single argument is of type GLenum, and it tells you the specific error that occurred. There are 37 errors unique to NURBS, named GLU_NURBS_ERROR1 through GLU_NURBS_ERROR37. If you want the character strings describing these errors, grab them with gluErrorString. 🧚


⭐ NOTES ⭐

gluNurbsCallback is available only if the GLU version is 1.2 or greater. So check ur version, bestie.

GLU version 1.2 supports only the GLU_ERROR parameter for which. And plot twist: GLU_ERROR is deprecated in GLU version 1.3 in favor of GLU_NURBS_ERROR. All the other accepted values for CallBackFunc are available only if the GLU version is 1.3 or greater.

πŸ‘‘ Real talk: don't build new stuff on GLU_ERROR. It's giving deprecated. Use GLU_NURBS_ERROR if your GLU is 1.3+.

πŸ’œ SEE ALSO πŸ’œ

  • gluErrorString(3G)
  • gluNewNurbsRenderer(3G)
  • gluNurbsCallbackData(3G)
  • gluNurbsProperty(3G)

And that's the whole page, bestie! πŸŽ€ This was GLUNURBSCALLBACK(3G) β€” that's the title up top and the footer down bottom, same name both times, no cap. Sending you so much love from the 3G GLU manual, wherever and whenever this edition shipped. Go make some cursed-but-gorgeous NURBS surfaces. Slay. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from