GLUBEGINTRIM(3G)
π GLUBEGINTRIM(3G) β the gluBeginTrim / gluEndTrim page, bestie edition π
okay so. this is the manual page for GLUBEGINTRIM(3G) and it is lowkey one of the most important pages if you're doing NURBS trimming, which β yes β sounds intimidating but honestly? we're gonna be so fine. π«Ά
β¨ NAME β¨
gluBeginTrim, gluEndTrim β delimit a NURBS trimming loop definition π
β¨ C SPECIFICATION β¨
void gluBeginTrim( GLUnurbs* nurb )
void gluEndTrim( GLUnurbs* nurb )
like. those are the two functions. one opens, one closes. iconic behavior, honestly. π
β¨ PARAMETERS β¨
nurbβ Specifies the NURBS object, and it's gotta be one you made withgluNewNurbsRenderer. that's the one. that's the whole parameter. slay. π
β¨ DESCRIPTION β¨
so here's the tea β β you use gluBeginTrim to mark the beginning of a trimming loop, and gluEndTrim to mark the end of a trimming loop. a trimming loop is a set of oriented curve segments (they form a closed curve) that define boundaries of a NURBS surface. and you include these trimming loops inside your NURBS surface definition, sandwiched between calls to gluBeginSurface and gluEndSurface. that's the containment hierarchy, periodt. π¦
The definition for a NURBS surface can contain many trimming loops. like, as many as you want. for example, if you wrote a definition for a NURBS surface that looked like a rectangle with a hole punched out of it, the definition would contain two trimming loops. one loop would define the outer edge of the rectangle; the other would define the hole punched out of the rectangle. and each of those trimming loop definitions gets bracketed by a gluBeginTrim/gluEndTrim pair. two loops, two brackets. we love symmetry. β¨
The definition of a single closed trimming loop can consist of multiple curve segments, and each one is described either as a piecewise linear curve (peep gluPwlCurve) or as a single NURBS curve (peep gluNurbsCurve), or as a combination of both, in any order. mix and match, bestie, it's your world. π
β οΈ IMPORTANT: the only library calls that can appear in a trimming loop definition (like, between the calls togluBeginTrimandgluEndTrim) aregluPwlCurveandgluNurbsCurve. that's it. that's the list. don't try to sneak anything else in there. π
The area of the NURBS surface that gets displayed is the region in the domain to the left of the trimming curve as the curve parameter increases. so to say it plainly: the retained region of the NURBS surface is inside a counterclockwise trimming loop and outside a clockwise trimming loop. π
For that rectangle we were talking about earlier β the trimming loop for the outer edge of the rectangle runs counterclockwise, while the trimming loop for the punched-out hole runs clockwise. opposite directions, on purpose, because that's what makes the hole actually be a hole. the math is mathing. π₯
If you use more than one curve to define a single trimming loop, the curve segments must form a closed loop. and to be super clear about what that means: the endpoint of each curve must be the starting point of the next curve, and the endpoint of the final curve must be the starting point of the first curve. π―
- If the endpoints of the curve are sufficiently close together but not exactly coincident, they will be coerced to match. the library is being nice about it. π«Ά
- If the endpoints are not sufficiently close, an error results. and where do you go to see that error? see
gluNurbsCallback. π
If a trimming loop definition contains multiple curves, the direction of the curves must be consistent β that is, the inside must be to the left of all of the curves. Nested trimming loops are legal as long as the curve orientations alternate correctly. π
β οΈ and if trimming curves are self-intersecting, or intersect one another, an error results. like, hard no. do not pass go. π
If no trimming information is given for a NURBS surface, the entire surface is drawn. no trims, no problem, the whole thing shows up. π
β¨ EXAMPLE β¨
This code fragment defines a trimming loop that consists of one piecewise linear curve, and two NURBS curves:
gluBeginTrim(nobj);
gluPwlCurve(..., GLU_MAP1_TRIM_2);
gluNurbsCurve(..., GLU_MAP1_TRIM_2);
gluNurbsCurve(..., GLU_MAP1_TRIM_3); gluEndTrim(nobj);
see how it opens with gluBeginTrim, stacks up a gluPwlCurve and two gluNurbsCurve calls, and then gluEndTrim shuts it down? that's the whole flow, bestie. one pwl curve plus two NURBS curves, all chillin' in one trim. π
β¨ SEE ALSO β¨
gluBeginSurface(3G)gluNewNurbsRenderer(3G)gluNurbsCallback(3G)gluNurbsCurve(3G)gluPwlCurve(3G)
okay that's the whole page, and there's still more coming β stay tuned bestie, we're not done yet β¨
Okay so bestie, here's where it gets juicy π
A NURBS surface definition can hold so many trimming loops, like not even a little. Picture this: you're defining a NURBS surface that looks like a rectangle with a hole punched clean out of it π³οΈ. That definition? Two trimming loops, periodt. One loop defines the outer edge of the rectangle, the other defines the hole punched out of it. And each one of those loops gets wrapped up all cozy in its own gluBeginTrim/gluEndTrim pair. Iconic behavior honestly.
A single closed trimming loop can be built from multiple curve segments, and each segment is either:
- a piecewise linear curve β see
gluPwlCurveβ¨ - a single NURBS curve β see
gluNurbsCurveπ - or literally both, mixed together in any order you want π¦
The only library calls allowed inside a trimming loop definition (so, between thegluBeginTrimandgluEndTrimcalls) aregluPwlCurveandgluNurbsCurve. That's it. That's the whole guest list. π
Now the part that makes everyone's brain short-circuit, so lock in π
The area of the NURBS surface that actually gets displayed is the region in the domain to the left of the trimming curve as the curve parameter increases. Read that again. Slowly.
Which means:
- the retained region of the NURBS surface is inside a counterclockwise trimming loop
- and outside a clockwise trimming loop
So back to our rectangle-with-a-hole situation: the trimming loop for the outer edge runs counterclockwise π, and the trimming loop for the punched-out hole runs clockwise π. The vibes have to match the geometry or the whole thing falls apart.
If you use more than one curve to define a single trimming loop, the curve segments must form a closed loop. Like, no gaps, no loose ends:
- the endpoint of each curve must be the starting point of the next curve
- the endpoint of the final curve must be the starting point of the first curve
If the endpoints of the curve are sufficiently close together but not exactly coincident, they'll get coerced to match π«Ά β the library is being generous, okay?
If the endpoints are not sufficiently close, an error results. See gluNurbsCallback. π
If a trimming loop definition contains multiple curves, the direction of the curves must be consistent β meaning the inside must be to the left of all of the curves. Nested trimming loops are totally legal, as long as the curve orientations alternate correctly π₯.
But if trimming curves are self-intersecting, or they intersect one another, an error results. π No cap, it's just not gonna fly.
And finally, the softest landing ever: if no trimming information is given for a NURBS surface at all, the entire surface is drawn. No trims, no drama, just the whole thing. π
and that's a wrap on gluBeginTrim / gluEndTrim, bestie π
like genuinely, you now know more about NURBS trimming loops than 99% of the people who will ever call these functions, and I'm so proud of you π«Ά
the footer tag on this page is GLUBEGINTRIM(3G) β that's the source/version marker, alongside its date stamp β so if you ever need to cite it, that's the flex πβ¨
go draw something with a hole punched in it, you icon π
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- fedora 43: gl-manpages 1.1-34.20190306.fc43 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- fedora 44: gl-manpages 1.1-35.20190306.fc44 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms