Time for action - generating a Bezier curve

OpenGL has provided functions to generate Bezier and NURBS curves and surfaces for years, but they are not as good as we wish. Today's geometry shader can do the same work in a more convenient and efficient way. Take the generation of a Cubic Bezier curve as an example. Given two endpoints, and two control points to the shader, it will then produce a smooth curve, with specific segments, that begins and ends at two different endpoints, and be pulled away towards the control points.

  1. Include the necessary headers. We'd like to change the output line width, so the osg::LineWidth class is used here, too:
    #include <osg/Program> #include <osg/LineWidth> #include <osgDB/ReadFile> #include <osgViewer/Viewer> ...

Get OpenSceneGraph 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.