The exampleCreator example uses the creator pattern to cause a derived channel to get created when the display engine creates a channel. Here is the object class:
{
public:
friend class MyExampleChannelCreator;
virtual ~MyExampleChannel()
{
}
protected:
MyExampleChannel(
DtDe& de,
DtOsgWindow* window, DtChannelConfiguration& channelConfig )
{
}
};
Notice the protected constructor. This is because we are going to use a creator to create our channel. Here is the creator for the object class:
{
public:
virtual DtChannel* create(
DtDe& de, DtWindow* window,
DtChannelConfiguration& config )
{
return new MyExampleChannel( de, dynamic_cast<DtOsgWindow*>(window), config );
}
};
This creator is derived from the DtChannelCreator (DtChannel.h):
Building the Example
VR-Vantage includes pre-built versions of the example application. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.
Running the Example
This example is an application. You can run it by running ./bin/exampleCreator.exe (on Windows) or ./bin/exampleCreator (on Linux). For more information about running examples, please see Running Applications and Examples.
exampleCreator.cxx
#include <vrvCore/DtVrvApplication.h>
#include <vrvOsg/DtOsgChannel.h>
#include <vrvOsg/DtOsgWindow.h>
#include <boost/bind.hpp>
using namespace makVrv;
{
public:
friend class MyExampleChannelCreator;
virtual ~MyExampleChannel()
{
}
protected:
MyExampleChannel(
DtDe& de,
DtOsgWindow* window, DtChannelConfiguration& channelConfig )
{
}
};
{
public:
virtual DtChannel* create(
DtDe& de, DtWindow* window,
DtChannelConfiguration& config )
{
return new MyExampleChannel( de, dynamic_cast<DtOsgWindow*>(window), config );
}
};
{
public:
MyExampleApplication()
{
DtVrvApplication::ApplicationTransform functor = boost::bind(
&MyExampleApplication::postLoadPluginModules, this, _1, _2, _3 );
installPostPluginTransform( functor, "postPluginTransform" );
}
protected:
virtual void postLoadPluginModules( DtDeInitializer& deInit,
DtDe& de,
{
DtChannelCreator::registerInstance( *myDe, new MyExampleChannelCreator() );
}
};
int main( int argc,char* argv[] )
{
MyExampleApplication application;
application.initialize(argc, argv);
application.run();
}