Equalizer 1.0
|
00001 00002 /* Copyright (c) 2010, Stefan Eilemann <eile@eyescale.ch> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * Redistributions of source code must retain the above copyright notice, this 00008 * list of conditions and the following disclaimer. Redistributions in binary 00009 * form must reproduce the above copyright notice, this list of conditions and 00010 * the following disclaimer in the documentation and/or other materials provided 00011 * with the distribution. Neither the name of Eyescale Software GmbH nor the 00012 * names of its contributors may be used to endorse or promote products derived 00013 * from this software without specific prior written permission. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00016 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00017 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00018 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00019 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00020 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00021 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00024 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00025 * POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00028 #ifndef EQ_ADMIN_ADD_WINDOW_H 00029 #define EQ_ADMIN_ADD_WINDOW_H 00030 00031 #include "findPipe.h" 00032 00033 #include <eq/admin/base.h> 00034 00035 namespace eqAdmin 00036 { 00037 00038 inline bool addWindow( eq::admin::ServerPtr server, const bool passiveStereo ) 00039 { 00040 if( !server ) 00041 return false; 00042 00043 // Find first pipe... 00044 eq::admin::Pipe* pipe = findPipe( server ); 00045 if( !pipe ) 00046 return false; 00047 00048 // Add window (->channel->segment->canvas->layout->view) 00049 eq::admin::Config* config = pipe->getConfig(); 00050 eq::admin::Window* window = new eq::admin::Window( pipe ); 00051 eq::admin::Channel* channel = new eq::admin::Channel( window ); 00052 eq::admin::Canvas* canvas = new eq::admin::Canvas( config ); 00053 eq::admin::Segment* segment = new eq::admin::Segment( canvas ); 00054 eq::admin::Layout* layout = new eq::admin::Layout( config ); 00055 eq::admin::View* view = new eq::admin::View( layout ); 00056 eq::admin::Observer* observer = new eq::admin::Observer( config ); 00057 00058 window->setPixelViewport( eq::fabric::PixelViewport( 100, 100, 400, 300 )); 00059 channel->setName( "Runtime-created channel" ); 00060 canvas->setName( "Runtime-created canvas" ); 00061 layout->setName( "Runtime-created layout" ); 00062 view->setName( "Runtime-created view" ); 00063 observer->setName( "Runtime-created observer" ); 00064 view->changeMode( eq::admin::View::MODE_STEREO ); 00065 00066 if( passiveStereo ) 00067 { 00068 window->setName( "Passive stereo window" ); 00069 window->setPixelViewport( 00070 eq::fabric::PixelViewport( 500, 100, 400, 300 )); 00071 segment->setEyes( eq::fabric::EYE_CYCLOP ); // Mono 00072 view->changeMode( eq::admin::View::MODE_MONO ); 00073 00074 // Passive stereo 00075 eq::admin::Channel* channelLeft = new eq::admin::Channel( window ); 00076 eq::admin::Channel* channelRight = new eq::admin::Channel( window ); 00077 00078 eq::admin::Segment* segmentLeft = new eq::admin::Segment( canvas ); 00079 eq::admin::Segment* segmentRight = new eq::admin::Segment( canvas ); 00080 00081 channelLeft->setViewport( eq::fabric::Viewport( .0f, 0.f, .5f, 1.f )); 00082 segmentLeft->setEyes( eq::fabric::EYE_LEFT ); 00083 segmentLeft->setChannel( channelLeft ); 00084 00085 channelRight->setViewport( eq::fabric::Viewport( .5f, 0.f, .5f, 1.f )); 00086 segmentRight->setEyes( eq::fabric::EYE_RIGHT ); 00087 segmentRight->setChannel( channelRight ); 00088 00089 channelLeft->setName( "Runtime-created left eye channel" ); 00090 channelRight->setName( "Runtime-created right eye channel" ); 00091 } 00092 else 00093 window->setName( "Active stereo window" ); 00094 00095 view->setObserver( observer ); 00096 segment->setChannel( channel ); 00097 canvas->addLayout( layout ); 00098 canvas->setWall( eq::fabric::Wall( eq::fabric::Vector3f(-.4f,-.3f,-1.f ), 00099 eq::fabric::Vector3f( .4f,-.3f,-1.f ), 00100 eq::fabric::Vector3f(-.4f, .3f,-1.f ))); 00101 config->commit(); 00102 return true; 00103 } 00104 00105 } 00106 00107 #endif // EQ_ADMIN_ADD_WINDOW_H