VR-Vantage
Loading...
Searching...
No Matches
exampleChannelPlugin

Overview

This example shows how to register a creator function using a plugin. In this example, a new creator function is added for creating channels, but the concept applies for adding any kind of creator with a plugin.

Expected Result

Channel Plugin Result

Example details

The files DtExampleChannel.h and DtExampleChannel.cxx declare and define, respectively, the new type of channel to be created.

class DT_DLL_EXAMPLECHANNELPLUGIN DtExampleChannel : public DtOsgChannel
#define DT_DLL_EXAMPLECHANNELPLUGIN
Definition exampleChannelPlugin.h:19
{
public:
friend class DtExampleChannelCreator;
virtual ~DtExampleChannel();
protected:
DtExampleChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& channelConfig);
virtual bool initialize() override;
};
DtExampleChannel::DtExampleChannel( DtDe& de, DtOsgWindow* window, DtChannelConfiguration& channelConfig )
: DtOsgChannel(de, window, channelConfig)
{
// Do nothing. This is an example of registering a class using the creator pattern
// via a plugin.
}
DtExampleChannel::~DtExampleChannel()
{
}

They also declare and define the creator function that will be registered by the plugin.

class DT_DLL_EXAMPLECHANNELPLUGIN DtExampleChannelCreator : public DtChannelCreator
{
public:
virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config) override;
};
DtChannel* DtExampleChannelCreator::create( DtDe& de, DtWindow* window, DtChannelConfiguration& config )
{
DtOsgWindow* osgWindow = dynamic_cast<DtOsgWindow*>(window);
if (!osgWindow)
{
return 0;
}

exampleChannelPluginInit.h declares the plugin initialization method.

DT_DLL_EXAMPLEACCESSORY void init(makVrv::DtDe &de)
}

Finally, exampleChannelPluginInit.cxx performs the standard plugin initialization in its init() method and registers the creator function for DtExampleChannel.

#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
try
{
// First make sure that the vrvOsg module is init'ed because that
// library registers its own DtOsgChannelCreator instance with the
// display engine. If you do not init vrvOsg before registering the
// example's custom channel creator instance, there is a chance
// that DtOsgChannelCreator will be registered with the display
// engine AFTER this example registers its channel creator instance
// - which will ultimately result in the DtExampleChannelCreator
// instance NOT being used by VR-Vantage
vrvOsg::init(de);
// Setup the channel creator.
DtChannelCreator::registerInstance(de, new DtExampleChannelCreator);
}
DtCATCH_AND_PROPAGATE(DtCorruptedState)

Building the Example

VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.

Running the Example

This example is a plug-in. You can run it by running ./bin64/exampleChannelPlugin_stealth.bat (on Windows) or ./bin64/exampleChannelPlugin_stealth.sh (on Linux). Select the menu "view->Display Engine Configuration Editor Panel", this will display the created channel with the custom name. For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleChannelPluginInit.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
// Get proper local export symbol
// Setup proper plugin export symbol
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLECHANNELPLUGIN
// Export plugging function bool initDeModule(DtDe* de);
namespace makVrv
{
class DtDe;
namespace vrvExampleChannelPlugin
{
}
}
Contains DLL export macros.
DT_DLL_EXAMPLECHANNELPLUGIN void init(DtDe &anIG)
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16

exampleChannelPlugin.h

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#ifndef exampleChannelPlugin_H_
#define exampleChannelPlugin_H_
#ifdef _WIN32
#ifdef EXAMPLECHANNELPLUGIN_EXPORTS
#define DT_DLL_EXAMPLECHANNELPLUGIN __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLECHANNELPLUGIN __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLECHANNELPLUGIN
#endif
#endif

exampleChannelPluginInit.cxx

/******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvOsg/vrvOsg.h>
#include <vrvCore/DtDe.h>
{
return true;
}
namespace makVrv
{
namespace vrvExampleChannelPlugin
{
void init(DtDe& de)
{
try
{
// First make sure that the vrvOsg module is init'ed because that
// library registers its own DtOsgChannelCreator instance with the
// display engine. If you do not init vrvOsg before registering the
// example's custom channel creator instance, there is a chance
// that DtOsgChannelCreator will be registered with the display
// engine AFTER this example registers its channel creator instance
// - which will ultimately result in the DtExampleChannelCreator
// instance NOT being used by VR-Vantage
// Setup the channel creator.
DtChannelCreator::registerInstance(de, new DtExampleChannelCreator);
}
DtCATCH_AND_PROPAGATE(DtCorruptedState)
}
}
}
Contains makVrv::DtChannel class.
Contains makVrv::DtDe class.
Contains makVrv::DtExampleChannel class.
static void registerInstance(DtDe &de, DtChannelCreator *instance)
Register the creator instance with an IG.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
DT_DLL_VRVOSG void init(DtDe &anIG, bool initOpenGL=true)
Contains DLL export macros.