Summary

This chapter provided a simple guide to creating your own simple OSG program with the CMake tool, and introduced some practical utilities. OSG uses smart pointers heavily for efficient manipulation of operating system resources allocated for each scene graph node at run time, which is crucial to the performance of these safety-critical programs. To help understand the working principle of smart pointers, we spent much of the chapter explaining the use of osg::ref_ptr<> and how to calculate the referenced count, and discussing various situations that may occur when managing OSG scene elements.

In this chapter, we specifically covered:

  • How to write a simple CMake script file and make it work with your own source code and OSG dependencies
  • The principle of smart pointers and the garbage collection mechanism of OSG
  • Advantages and notes on using the native smart pointers with scene graph objects
  • Some other useful classes and functions for parsing command-line arguments, and tracing and debugging your source code