OpenSceneGraph on Linux

Welcome to this tutorial for running OpenSceneGraph on Linux (Debian based) machine. I’m currently using Linux Mint 15 but it would be quite easy to follow along on any other Debian based OS. Let’s get started shall we!

Brief Introduction
The OpenSceneGraph is an open source high performance 3D graphics toolkit. It is a real-time graphics middle-ware used by application developers in fields that range from visual simulation (flight, marine, vehicle, space simulator) to virtual and augmented reality, to medical and scientific visualisation, to education and games. Written entirely in Standard C++ and OpenGL it runs on all Windows platforms, OSX, GNU/Linux, IRIX, Solaris, HP-Ux, AIX and FreeBSD operating systems.

You can get more information at the official website: OpenSceneGraph

Downloading Source
You can download the openscenegraph source from one the following:

  1. Stable Release Section
  2. Code Repositories
  3. Developer Releases

Download the .zip file and extract its contents in OpenSceneGraph folder in your home.

Downloading the Dependencies
You need to download the necessary dependencies to be able to compile OpenSceneGraph.

  • Run the following command to download and install the necessary dependencies.

    apt-get build-dep openscenegraph

  • Or you can download .7z file from this page. And merge the files from this to the OpenSceneGraph folder in your home, for example, copy files from bin folder from .7z file to the bin folder in OpenSceneGraph folder. Do this for all the folders in .7z file.

The 2nd method is recommended for building.

CMake Tool
Make sure you have cmake tool installed on your system in order to compile OpenSceneGraph. If not, follow steps on their website.

Downloading the Data Resources
OpenSceneGraph standard dataset is required for use the with openscenegraph-examples. You can download it from this page.
Extract the contents of .zip file in the OpenSceneGraph-Data folder in your home.

Now it’s time to compile. Run these commands in your terminal:

cd OpenSceneGraph
sudo make install

Running the Examples
Now our OpenSceneGraph has been built/compiled, its time to check it by running examples. But before we do that we need to place the location where it was installed on the system paths environmental variables. Edit your .bashrc file, add following lines in it:

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

Replace myaccount with your useraccount name.

Now we need to build the examples. Use following commands for building:

cd OpenSceneGraph

After the examples has been built you can run them, still in OpenSceneGraph folder, use following command:

sh ./runexamples.bat

Press Escape key to move to the next example.

That’s it! Enjoy OSG!