![]() |
VR-Vantage 1.4.1 API Class Documentation
|
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);
2. 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);
3. 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.
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.
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.
// /****************************************************************************** // ** Copyright (c) 2008 MAK Technologies, Inc. // ** All rights reserved. // ******************************************************************************/ // /****************************************************************************** // ** $RCSfile: exampleConfiguration.cxx,v $ $Revision: 1.15 $ $State: Exp $ // ******************************************************************************/ #include <vrvCore/DtVrvApplication.h> #include <vrvCore/DtDe.h> #include <vrvCore/DtDeCommunicator.h> #include <vrvUtil/DtWindowConfiguration.h> #include <vrvUtil/DtChannelConfiguration.h> #include <vrvUtil/DtDisplayConfiguration.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". std::string cName = DtChannelConfiguration::DefaultChannelString; cName += " 1"; DtChannelConfiguration cc1(cName); // Create a window to hold the channel, giving it a unique name of "Window 1". 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); // // The second window // // Configure a channel for the next window, "Channel 2" cName = DtChannelConfiguration::DefaultChannelString; cName += " 2"; DtChannelConfiguration cc2(cName); // Create a window to hold the channel, giving it a unique name of "Window 1". wName = DtWindowConfiguration::DefaultWindowString; wName += " 2"; DtWindowConfiguration wc2(wName); // 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. DtDisplayConfiguration dc; std::string deName = "My Display Configuration"; dc.setName(deName); dc.windowConfigurations().add(wc1); dc.windowConfigurations().add(wc2); 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). DtVrvApplication vrvApp; // 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(); }