/ Running the examples


Running the examples

 The OpenSceneGraph has an ever growing number of examples available for developers to learn from. Following is a guide to getting these examples running.

Once the OpenSceneGraph is installed you will need to place the location where it was installed on the system paths environmental variables. Also download the demo data and set the OSG_FILE_PATH environment variable so that the example datasets can be found by OSG. It is probably worth setting your autoexec.bat, .bashrc, .tcsh, etc to pick up on these settings so that next time you log in everything is in easy reach. Below are examples for the different platforms on how to set up your environment. The examples are not built by default, use the cmake utility and set the option to enable building of the example applications. To build them, run cmake with the following parameter: -DBUILD_OSG_EXAMPLES=1

  • Windows:
    set PATH=path;C:\OpenSceneGraph\bin
    set OSG_FILE_PATH=C:\OpenSceneGraph-Data;C:\OpenSceneGraph-Data\Images
  • Unix - bashrc:
    export PATH = ${PATH}:/home/myaccount/OpenSceneGraph/bin
    export LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/home/myaccount/OpenSceneGraph/lib
    export OSG_FILE_PATH = /home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images
  • Unix - tcsh:
    setenv PATH ${PATH}:/home/myaccount/OpenSceneGraph/bin
    setenv LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}:/home/myaccount/OpenSceneGraph/lib
    setenv OSG_FILE_PATH /home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images
  • MacOSX:
    setenv PATH "${PATH}:${OSGHOME}/lib:${OSGHOME}/lib/osgPlugins"
    setenv DYLD_LIBRARY_PATH "${OSGHOME}/lib:${OSGHOME}/lib/osgPlugins"
    setenv OSG_FILE_PATH "/home/myaccount/OpenSceneGraph-Data:/home/myaccount/OpenSceneGraph-Data/Images"

All the examples run from the command-line. Most require parameters to be passed, such as what file to load. If you are in any doubt just run the application and it will either run, or provide help on what options it accepts. You can also print out full help my running the example with the option --help.

To run the examples in quick succession on Windows, use the runexamples.bat script which can be found in the the root of the OpenSceneGraph distribution:


Press Escape to close each application and move on to the next application. On Unix, you should be able to use

sh ./runexamples.bat