osgEarth 2.1.1
Functions | Variables

/home/cube/sources/osgearth/src/applications/osgearth_shadercomp/osgearth_shadercomp.cpp File Reference

#include <osg/Notify>
#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarth/ShaderComposition>
#include <osgEarth/Registry>
Include dependency graph for osgearth_shadercomp.cpp:

Go to the source code of this file.

Functions

osg::StateAttribute * createHaze ()
int usage (const std::string &msg)
int main (int argc, char **argv)

Variables

static char s_hazeVertShader [] = "} \n"
static char s_hazeFragShader [] = "} \n"

Function Documentation

osg::StateAttribute * createHaze ( )

This sample demonstrates a simple use of osgEarth's shader composition framework.

By default, osgEarth uses GL shaders to render the terrain. Shader composition is a mechanism by which you can inject custom shader code into osgEarth's shader program pipeline. This gets around the problem of having to duplicate shader code in order to add functionality.

Definition at line 95 of file osgearth_shadercomp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 47 of file osgearth_shadercomp.cpp.

{
    osg::ArgumentParser arguments(&argc,argv);

    osg::Node* earthNode = osgDB::readNodeFiles( arguments );
    if (!earthNode)
    {
        return usage( "Unable to load earth model." );
    }

    osg::Group* root = new osg::Group();
    root->addChild( earthNode );
    
    osgViewer::Viewer viewer(arguments);
    viewer.setCameraManipulator( new osgEarth::Util::EarthManipulator() );
    viewer.setSceneData( root );

    // inject the haze shader components:
    root->getOrCreateStateSet()->setAttributeAndModes( createHaze(), osg::StateAttribute::ON );

    // add some stock OSG handlers:
    viewer.addEventHandler(new osgViewer::StatsHandler());
    viewer.addEventHandler(new osgViewer::WindowSizeHandler());
    viewer.addEventHandler(new osgViewer::ThreadingHandler());
    viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));

    return viewer.run();
}

Here is the call graph for this function:

int usage ( const std::string &  msg)

Definition at line 38 of file osgearth_shadercomp.cpp.

{    
    OE_NOTICE
        << msg << std::endl
        << "USAGE: osgearth_shadercomp <earthfile>" << std::endl;

    return -1;
}

Variable Documentation

char s_hazeFragShader[] = "} \n" [static]

Definition at line 85 of file osgearth_shadercomp.cpp.

char s_hazeVertShader[] = "} \n" [static]

Definition at line 78 of file osgearth_shadercomp.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines