You are on page 1of 7

Build OpenSceneGraph and Examples on Windows

What is OpenSceneGraph?

The OpenSceneGraph is an open source high performance 3D graphics toolkit, used by


application developers in fields such as visual simulation, games, virtual reality, scientific
visualization and modeling.

Step 0: Set up Build Environment on Windows


Install Visual Studio 2008 Professional Visual Studio Professional 2008 or Visual Studio
Express 2008 (free). If you are using Visual Studio 2008 Express, don’t forget to install Visual
Studio 2008 Service Pack 1 SDK, which is necessary

Step1: Obtain OpenSceneGraph Code


Create a OpenGL directory in C:\Documents and Settings\<user>\My Documents\OpenGL

Download OpenSceneGraph source from OSG download page, unzip it to C:\Documents and
Settings\<user>\My Documents\OpenGL
Step2: Obtain Third Party Library from OSG Site
Download third party library zipped file

Then unzip it to:

C:\Documents and Settings\<user>\My Documents\OpenGL¥<OpenSceneGraphSrc>¥third-party

In our case, it’s


C:\Documents and Settings\<user>\My Documents\OpenGL¥OpenSceneGraph-2.8.2-rc2¥third-party
Step3: Generate Solution File from Source Using CMake

Download CMake if not already installed. Start CMake GUI by double click CMakeSetup.exe,
then select the OpenSceneGraph source directory ( in our case, C:\Documents and Settings\<user>\My
Documents\OpenGL¥<OpenSceneGraphSrc> ) for both “where is the source code” and “where to build
the binaries”.

Make sure you set the ACTUAL_3DPARTY_DIR correctly or else you will have linking errors.
Set BUILD_MFC_EXAMPLE, BUILD_OSG_APPLICATIONS, and
BUILD_OSG_EXAMPLES to ON. Also, delete string in SMAKE_DEBUG_POSTFIXThen
Click Configure to update and display new values in red.
Then press OK to generate selected build files and exit.

When CMake is done, there should be an OpenSceneGraph.sln file in the


OpenSceneGraph-2.8.2-rc2 directory.
Double click OpenSceneGraph.sln to open the solution. If you would like to run the
runexample.bat batch file, which runs all examples in batch mode, then set the build mode to
RELEASE. To do so, right click on the OpenSceneGraph solution, select Properties.

Set the Configuration from Active (Debug) to Release.


After saving the new configuration , go to Solution->Rebuild to build everything, including
OpenSceneGraph library, plugins, applications, and examples.

When learning anything technology new, I find it easier to look at examples. And
OpenSceneGraph provides so many examples and they build without much tweaking. I am truly
impressed.
Step 4: Set System Environment Variables

Before running the examples from OpenSceneGraph, add the following path to the Path system
variable:
C:\Documents and Settings\u1\My Documents\OpenGL\OpenSceneGraph-2.8.2-rc2\3rdParty\bin

If you have linking errors when you run the examples, make sure your path is set correctly so
that all relevant dlls can be found.

Step 5: Run several examples from OpenSceneGraph source code

Just double click the runexamples.bat and let yourself be amazed. This is a snapshot of a chess
board.

You might also like