Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
addWindow.h
1 
2 /* Copyright (c) 2010, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer. Redistributions in binary
9  * form must reproduce the above copyright notice, this list of conditions and
10  * the following disclaimer in the documentation and/or other materials provided
11  * with the distribution. Neither the name of Eyescale Software GmbH nor the
12  * names of its contributors may be used to endorse or promote products derived
13  * from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef EQ_ADMIN_ADD_WINDOW_H
29 #define EQ_ADMIN_ADD_WINDOW_H
30 
31 #include "findPipe.h"
32 
33 #include <eq/admin/base.h>
34 
35 namespace eqAdmin
36 {
37 
38 inline bool addWindow( eq::admin::ServerPtr server, const bool passiveStereo )
39 {
40  if( !server )
41  return false;
42 
43  // Find first pipe...
44  eq::admin::Pipe* pipe = findPipe( server );
45  if( !pipe )
46  return false;
47 
48  // Add window (->channel->segment->canvas->layout->view)
49  eq::admin::Config* config = pipe->getConfig();
50  eq::admin::Window* window = new eq::admin::Window( pipe );
51  eq::admin::Channel* channel = new eq::admin::Channel( window );
52  eq::admin::Canvas* canvas = new eq::admin::Canvas( config );
53  eq::admin::Segment* segment = new eq::admin::Segment( canvas );
54  eq::admin::Layout* layout = new eq::admin::Layout( config );
55  eq::admin::View* view = new eq::admin::View( layout );
56  eq::admin::Observer* observer = new eq::admin::Observer( config );
57 
60  window->setPixelViewport( eq::fabric::PixelViewport( 100, 100, 400, 300 ));
61  channel->setName( "Runtime-created channel" );
62  canvas->setName( "Runtime-created canvas" );
63  layout->setName( "Runtime-created layout" );
64  view->setName( "Runtime-created view" );
65  observer->setName( "Runtime-created observer" );
66  view->changeMode( eq::admin::View::MODE_STEREO );
67 
68  if( passiveStereo )
69  {
70  window->setName( "Passive stereo window" );
71  window->setPixelViewport(
72  eq::fabric::PixelViewport( 500, 100, 400, 300 ));
73  segment->setEyes( eq::fabric::EYE_CYCLOP ); // Mono
74  view->changeMode( eq::admin::View::MODE_MONO );
75 
76  // Passive stereo
77  eq::admin::Channel* channelLeft = new eq::admin::Channel( window );
78  eq::admin::Channel* channelRight = new eq::admin::Channel( window );
79 
80  eq::admin::Segment* segmentLeft = new eq::admin::Segment( canvas );
81  eq::admin::Segment* segmentRight = new eq::admin::Segment( canvas );
82 
83  channelLeft->setViewport( eq::fabric::Viewport( .0f, 0.f, .5f, 1.f ));
84  segmentLeft->setEyes( eq::fabric::EYE_LEFT );
85  segmentLeft->setChannel( channelLeft );
86 
87  channelRight->setViewport( eq::fabric::Viewport( .5f, 0.f, .5f, 1.f ));
88  segmentRight->setEyes( eq::fabric::EYE_RIGHT );
89  segmentRight->setChannel( channelRight );
90 
91  channelLeft->setName( "Runtime-created left eye channel" );
92  channelRight->setName( "Runtime-created right eye channel" );
93  }
94  else
95  window->setName( "Active stereo window" );
96 
97  view->setObserver( observer );
98  view->setWall( eq::fabric::Wall( eq::fabric::Vector3f(-.4f,-.3f,-1.f ),
99  eq::fabric::Vector3f( .4f,-.3f,-1.f ),
100  eq::fabric::Vector3f(-.4f, .3f,-1.f )));
101  segment->setChannel( channel );
102  canvas->addLayout( layout );
103 
104  config->commit();
105  return true;
106 }
107 
108 }
109 
110 #endif // EQ_ADMIN_ADD_WINDOW_H
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
monoscopic 'middle' eye
Definition: fabric/eye.h:39
A wall defining a view frustum.
Definition: wall.h:36
Window drawable (WindowSettings::IATTR_HINT_DRAWABLE)
Definition: iAttribute.h:46
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34