- Forward


Bézier Curves in OpenGL
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Review of Bézier Curves
Back SMYC Forward
  • Recall from our Discussion of Curves:
    • Cubic Bézier Curves use four points, \(\bs{q}_0, \bs{q}_1, \bs{q}_2, \bs{q}_3, \), but don't have the curve pass through all of them
    • Two, \(\bs{q}_0, \bs{q}_3, \), are the end points and two, \(\bs{q}_1, \bs{q}_2\), are used to approximate the tangents at the end points
  • A Visualization:
    • curve-cubic
Bézier Curves in OpenGL
Back SMYC Forward
  • Evaluators:
    • Compute the values for Bernstein polynomials of any order
  • Types:
    • Points/vertices are the most common (e.g., GL_MAP1_VERTEX_3)
    • Can also be used for colors, normals, and textures
    • Must be enabled using glEnable() (e.g., glEnable(GL_MAP1_VERTEX_3))
  • Arguments:
    • umin and umax define the range of the parameter (usually 0 and 1)
    • stride is the number of values of the parameter between curve segments
    • order is the degree of the polynomial plus 1
Bézier Curves in OpenGL (cont.)
Back SMYC Forward
Using an Evaluator
To Generate Points/Line Strips
openglexamples/curves/draw.c (Fragment: curve)
 
Bézier Curves in OpenGL (cont.)
Back SMYC Forward
Using Evenly Spaced Points
openglexamples/curves/drawWithMesh.c (Fragment: mesh)
 
A Curve Drawing Program
Back SMYC Forward
Adding Points
openglexamples/curves/draw.c (Fragment: mouse)
 
A Curve Drawing Program (cont.)
Back SMYC Forward
Moving Points
openglexamples/curves/draw.c (Fragment: motion)
 
A Curve Drawing Program (cont.)
Back SMYC Forward
Drawing the Points
openglexamples/curves/draw.c (Fragment: points)
 
There's Always More to Learn
Back -