Computer Graphics

OpenGL Bézier-Spline Curve Functions

  • We specify parameters and activate the routines for Bézier-curve display with the OpenGL functions
glMap1* (GL_MAP1_VERTEX_3, uMin, uMax, stride, nPts, *ctrlPts);

glEnable (GL_MAP1_VERTEX_3);
  • We deactivate the routines with
glDisable (GL_MAP1_VERTEX_3);

where,

  •  A suffix code of f or d is used with glMap1 to indicate either floating-point or doubleprecision for the data values.
  • Minimum and maximum values for the curve parameter u are specified in uMin and uMax, although these values for a Bézier curve are typically set to 0 and 1.0, respectively.
  • Bézier control points are listed in array ctrlPts number of elements in this array is given as a positive integer using parameter nPts.
  • [wp_ad_camp_1]

  • stride is assigned an integer offset that indicates the number of data values between the beginning of one coordinate position in array ctrlPts and the beginning of the next coordinate position
  •  A coordinate position along the curve path is calculated with glEvalCoord1* (uValue); Where,
  •  parameter uValue is assigned some value in the interval from uMin to uMax.
  • Function glEvalCoord1 calculates a coordinate position using equation with the parameter value

which maps the uValue to the interval from 0 to 1.0.

  • A spline curve is generated with evenly spaced parameter values, and OpenGL provides the following functions, which we can use to produce a set of uniformly spaced parameter values:
glMapGrid1* (n, u1, u2);

glEvalMesh1 (mode, n1, n2);

Where,
[wp_ad_camp_1]

  •  The suffix code for glMapGrid1 can be either f or d.
  • Parameter n specifies the integer number of equal subdivisions over the range from u1 to u2.
  •  Parameters n1 and n2 specify an integer range corresponding to u1 and u2.
  • Parameter mode is assigned either GL POINT or GL LINE, depending on whether we want to display the curve using discrete points (a dotted curve) or using straight-line segments
  • In other words, with mode = GL LINE, the preceding OpenGL commands are equivalent to
glBegin (GL_LINE_STRIP);

for (k = n1; k <= n2; k++)

glEvalCoord1f (u1 + k * (u2 - u1) / n);

glEnd ( );

Leave a comment

Your email address will not be published. Required fields are marked *