Overview
Creates and registers your own channel with the DtDisplayEngine.
Expected Result
Channel Creator Result
Example details
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:
class MyExampleChannel : public DtOsgChannel
{
public:
friend class MyExampleChannelCreator;
virtual ~MyExampleChannel()
{
}
protected:
MyExampleChannel( DtDe& de, DtOsgWindow* window, DtChannelConfiguration& channelConfig )
: DtOsgChannel( de, window, 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:
class MyExampleChannelCreator : public DtChannelCreator
{
public:
virtual DtChannel* create( DtDe& de, DtWindow* window,
DtChannelConfiguration& config )
{
DtOsgWindow* osgWindow = dynamic_cast<DtOsgWindow*>(window);
if (!osgWindow)
{
return 0;
}
MyExampleChannel* myExampleChannel = new MyExampleChannel(de, osgWindow, config);
if (myExampleChannel->initialize())
{
return myExampleChannel;
}
else
{
return 0;
}
}
};
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 ./bin64/exampleCreator.exe (on Windows) or ./bin64/exampleCreator (on Linux). For more information about running examples, please see Running Applications and Examples.
Example Source Files
exampleCreator.cxx
#include <boost/bind.hpp>
using namespace makVrv;
{
public:
friend class MyExampleChannelCreator;
virtual ~MyExampleChannel()
{
}
protected:
{
}
};
{
public:
{
if (!osgWindow)
{
return 0;
}
MyExampleChannel* myExampleChannel = new MyExampleChannel(de, osgWindow, config);
if (myExampleChannel->initialize())
{
return myExampleChannel;
}
else
{
return 0;
}
}
};
{
public:
MyExampleApplication()
{
&MyExampleApplication::postLoadPluginModules, this, _1, _2, _3 );
installPostPluginTransform( functor, "postPluginTransform" );
}
protected:
{
}
};
int main( int argc,char* argv[] )
{
MyExampleApplication application;
application.initialize(argc, argv);
application.run();
return 0;
}
[<< Examples] [Home] [Top of Page]