VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleConfiguration

This example shows how to create a display configuration.

You can create a display configuration (with any number of windows and channels) programmatically and then have it created by a display engine. Display configurations must have unique names. The display engine will prevent you from realizing configurations with duplicate names.

  1. Create a channel configuration giving it a unique name of "Channel 1" like this:
    std::string cName = DtChannelConfiguration::DefaultChannelString;
    cName += " 1";
    DtChannelConfiguration cc1(cName);
  1. Create a window configuration and add the channel configuration to it:

std::string wName = DtWindowConfiguration::DefaultWindowString;
wName += " 1";
DtWindowConfiguration wc1(wName);
// Set the window's type and position
wc1.setWindowType(DtWindowConfiguration::Window);
wc1.setPosition(100,100);
// Now add the channel config to the window config.
wc1.channelConfigurations().add(cc1);

  1. Add the window configuration to a display configuration:

DtDisplayConfiguration dc;
std::string deName = "My Display Configuration";
dc.setName(deName);
dc.windowConfigurations().add(wc1);
dc.windowConfigurations().add(wc2);

Once you have a display configuration, you must add it to the master display engine and tell the master display engine which display engine to create that configuration on. To try to add the configuration to the master display engine, do the following:

if(vrvApp.de().addDisplayConfiguration(dc))

If you are successful, tell it to create that configuration on a display engine. Here, we create it on the master display engine:

std::string displayName = vrvApp.de().igCommunicator().name();
vrvApp.de().realizeDisplayConfiguration(displayName, dc.name());

This causes the window and channel to be created on the master display engine.

Note: When you create a configuration, any previously created configurations are destroyed.

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/exampleConfiguration.exe (on Windows) or ./bin/exampleConfiguration (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleConfiguration.cxx

// /******************************************************************************
// ** Copyright (c) 2008 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
// /******************************************************************************
// ** $RCSfile: exampleConfiguration.cxx,v $ $Revision: 1.15 $ $State: Exp $
// ******************************************************************************/
#include <vrvCore/DtDe.h>
#include <iostream>
// Use the VR-Vantage namespace. All classes in VR-Vantage are in this namespace.
using namespace makVrv;
// This function creates a DtDisplayConfiguration that has two windows.
// Each window will have one channel.
DtDisplayConfiguration displayConfig()
{
//
// The first window
//
// Create a channel giving it a unique name of "Channel 1".
cName += " 1";
// Create a window to hold the channel, giving it a unique name of "Window 1".
wName += " 1";
// Set the window's type and position
wc1.setWindowType(DtWindowConfiguration::Window);
wc1.setPosition(100,100);
// Now add the channel config to the window config.
wc1.channelConfigurations().add(cc1);
//
// The second window
//
// Configure a channel for the next window, "Channel 2"
cName += " 2";
// Create a window to hold the channel, giving it a unique name of "Window 1".
wName += " 2";
// Set the window's type and position
wc2.setWindowType(DtWindowConfiguration::Window);
wc2.setPosition(500,100);
// Now add the channel config to the window config.
wc2.channelConfigurations().add(cc2);
// Configure a display and add both windows.
std::string deName = "My Display Configuration";
dc.setName(deName);
return dc;
}
//
// Create a display configuration and add it to the display engine programatically.
//
int main(int argc,char** argv)
{
// A DtVrvApplication wraps up all the components required to build a complete
// VR-Vantage application (DtDe, DtPluginManager, DtEventLoop, and a
// DtVrvApplicationConfiguration).
// This causes the plugin manager to load plugins, cause a Display Configuration
// to be realized, creates the default environment, etc.
vrvApp.initialize(argc, argv);
// Create a display configuration.
DtDisplayConfiguration dc = displayConfig();
// Try to add this configuration to the Display Engine.
if(vrvApp.de().addDisplayConfiguration(dc))
{
// Realize the display configuration on this display engine
// causing the windows and channels to be created.
std::string displayName = vrvApp.de().igCommunicator().name();
vrvApp.de().realizeDisplayConfiguration(displayName, dc.name());
}
else
{
std::cout << "Couldn't add display configuration: " << dc.name() << std::endl;
}
// Creates an event loop and begins running it, causing the creation of frames.
vrvApp.run();
}

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)