Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eVolve/pipe.cpp
1 
2 /*
3  * Copyright (c) 2006-2013, 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 eq::WindowSystem( 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 eq::uint128_t 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  sendError( ERROR_EVOLVE_LOADMODEL_FAILED ) << filename;
75  delete _renderer;
76  _renderer = 0;
77  return false;
78  }
79 
80  return mapped;
81 }
82 
84 {
85  delete _renderer;
86  _renderer = 0;
87 
88  eq::Config* config = getConfig();
89  config->unmapObject( &_frameData );
90 
91  return eq::Pipe::configExit();
92 }
93 
94 void Pipe::frameStart( const eq::uint128_t& frameID, const uint32_t frameNumber )
95 {
96  eq::Pipe::frameStart( frameID, frameNumber );
97  _frameData.sync( frameID );
98 
99  _renderer->setOrtho( _frameData.useOrtho( ));
100 }
101 }
A configuration is a visualization session driven by an application.
EQ_API EventOCommand sendError(const uint32_t error)
Send a pipe error event to the application node.
virtual EQ_API bool configInit(const uint128_t &initID)
Initialize this pipe.
virtual eq::WindowSystem selectWindowSystem() const
Choose the window system to be used by this pipe.
Definition: eVolve/pipe.cpp:47
virtual EQ_API bool configExit()
De-initialize this pipe.
virtual bool configExit()
De-initialize this pipe.
Definition: eVolve/pipe.cpp:83
EQ_API Config * getConfig()
virtual EQ_API bool mapObject(co::Object *object, const uint128_t &id, const uint128_t &version=co::VERSION_OLDEST)
Map a distributed object.
virtual bool configInit(const eq::uint128_t &initID)
Initialize this pipe.
Definition: eVolve/pipe.cpp:53
virtual void frameStart(const eq::uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
Definition: eVolve/pipe.cpp:94
virtual EQ_API void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
virtual EQ_API void unmapObject(co::Object *object)
Unmap a mapped object.