Time for action—say "Hello World" OSG style

Can't wait to have a taste of OSG programming? Here is the simplest example, which shows how to load an existing model file and render it on the screen. It is much more interesting than just printing a "Hello World" text on the console:

  1. Create a new project with any source code editor:
    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
    int main( int argc, char** argv )
    {
        osgViewer::Viewer viewer;
        viewer.setSceneData( osgDB::readNodeFile("cessna.osg") );
        return viewer.run();
    }
  2. Specify the OSG header location and dependent libraries. You need to tell the linker to link your project with five libraries: OpenThreads, osg, osgDB, osgUtil, and osgViewer. You will learn more about configuring an OSG application ...

Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.