Equalizer  1.6.1
eVolve/pipe.cpp
1 
2 /*
3  * Copyright (c) 2006-2010, Stefan Eilemann <eile@equalizergraphics.com>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  * - Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * - Neither the name of Eyescale Software GmbH nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28 
29  *
30  * The pipe object is responsible for maintaining GPU-specific and
31  * frame-specific data. The identifier passed by the application contains the
32  * version of the frame data corresponding to the rendered frame. The pipe's
33  * start frame callback synchronizes the thread-local instance of the frame data
34  * to this version.
35  */
36 
37 #include "pipe.h"
38 
39 #include "config.h"
40 #include "error.h"
41 #include "node.h"
42 
43 #include <eq/eq.h>
44 
45 namespace eVolve
46 {
48 {
49  const Config* config = static_cast<const Config*>( getConfig( ));
50  return config->getInitData().getWindowSystem();
51 }
52 
53 bool Pipe::configInit( const eq::uint128_t& initID )
54 {
55  if( !eq::Pipe::configInit( initID ))
56  return false;
57 
58  Config* config = static_cast<Config*>( getConfig( ));
59  const InitData& initData = config->getInitData();
60  const lunchbox::UUID frameDataID = initData.getFrameDataID();
61 
62  const bool mapped = config->mapObject( &_frameData, frameDataID );
63  LBASSERT( mapped );
64 
65  const std::string& filename = initData.getFilename();
66  const uint32_t precision = initData.getPrecision();
67  LBINFO << "Loading model " << filename << std::endl;
68 
69  _renderer = new Renderer( filename.c_str(), precision );
70  LBASSERT( _renderer );
71 
72  if( !_renderer->loadHeader( initData.getBrightness(), initData.getAlpha( )))
73  {
74  setError( ERROR_EVOLVE_LOADMODEL_FAILED );
75  LBWARN << getError() << ": " << filename << ".vhf" << std::endl;
76  delete _renderer;
77  _renderer = 0;
78  return false;
79  }
80 
81  return mapped;
82 }
83 
85 {
86  delete _renderer;
87  _renderer = 0;
88 
89  eq::Config* config = getConfig();
90  config->unmapObject( &_frameData );
91 
92  return eq::Pipe::configExit();
93 }
94 
95 void Pipe::frameStart( const eq::uint128_t& frameID, const uint32_t frameNumber )
96 {
97  eq::Pipe::frameStart( frameID, frameNumber );
98  _frameData.sync( frameID );
99 
100  _renderer->setOrtho( _frameData.useOrtho( ));
101 }
102 }
virtual eq::WindowSystem selectWindowSystem() const
Choose the window system to be used by this pipe.
Definition: eVolve/pipe.cpp:47
A configuration is a visualization session driven by an application.
virtual bool configExit()
De-initialize this pipe.
Definition: eVolve/pipe.cpp:84
virtual void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
virtual void frameStart(const eq::uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
Definition: eVolve/pipe.cpp:95
eq::fabric::Error getError() const
Definition: object.h:82
virtual void unmapObject(co::Object *object)
Unmap a mapped object.
Config * getConfig()
virtual bool mapObject(co::Object *object, const UUID &id, const uint128_t &version=co::VERSION_OLDEST)
Map a distributed object.
virtual bool configInit(const uint128_t &initID)
Initialize this pipe.
void setError(const int32_t error)
Set an error code why the last operation failed.
virtual bool configInit(const eq::uint128_t &initID)
Initialize this pipe.
Definition: eVolve/pipe.cpp:53
virtual bool configExit()
De-initialize this pipe.
The list of possible window systems.
Definition: windowSystem.h:68