examples/eVolve/pipe.cpp

00001 
00002 /* 
00003  * Copyright (c) 2006-2008, Stefan Eilemann <eile@equalizergraphics.com> 
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017 
00018  *
00019  * The pipe object is responsible for maintaining GPU-specific and
00020  * frame-specific data. The identifier passed by the application contains the
00021  * version of the frame data corresponding to the rendered frame. The pipe's
00022  * start frame callback synchronizes the thread-local instance of the frame data
00023  * to this version.
00024  */
00025 
00026 #include "pipe.h"
00027 #include "node.h"
00028 
00029 #include <eq/eq.h>
00030 
00031 using namespace eq::base;
00032 using namespace std;
00033 
00034 namespace eVolve
00035 {
00036 eq::WindowSystem Pipe::selectWindowSystem() const
00037 {
00038     const Node*            node     = static_cast< const Node* >( getNode( ));
00039     const InitData&        initData = node->getInitData();
00040     const eq::WindowSystem ws       = initData.getWindowSystem();
00041 
00042     if( ws == eq::WINDOW_SYSTEM_NONE )
00043         return eq::Pipe::selectWindowSystem();
00044     if( !supportsWindowSystem( ws ))
00045     {
00046         EQWARN << "Window system " << ws 
00047                << " not supported, using default window system" << endl;
00048         return eq::Pipe::selectWindowSystem();
00049     }
00050 
00051     return ws;
00052 }
00053 
00054 bool Pipe::configInit( const uint32_t initID )
00055 {
00056     if( !eq::Pipe::configInit( initID ))
00057         return false;
00058 
00059     const Node*     node        = static_cast<Node*>( getNode( ));
00060     const InitData& initData    = node->getInitData();
00061     const uint32_t  frameDataID = initData.getFrameDataID();
00062     eq::Config*     config      = getConfig();
00063 
00064     const bool mapped = config->mapObject( &_frameData, frameDataID );
00065     EQASSERT( mapped );
00066 
00067 
00068     const string&  filename  = initData.getFilename();
00069     const uint32_t precision = initData.getPrecision();
00070     EQINFO << "Loading model " << filename << endl;
00071 
00072     _renderer = new Renderer( filename.c_str(), precision );
00073     EQASSERT( _renderer );
00074 
00075     if( !_renderer->loadHeader( initData.getBrightness(), initData.getAlpha( )))
00076     {
00077         setErrorMessage( "Can't load model header file" );
00078         EQWARN << "Can't load model header file: " << filename << ".vhf"
00079                << endl;
00080         delete _renderer;
00081         _renderer = 0;
00082         return false;
00083     }
00084 
00085     return mapped;
00086 }
00087 
00088 bool Pipe::configExit()
00089 {
00090     delete _renderer;
00091     _renderer = 0;
00092 
00093     eq::Config* config = getConfig();
00094     config->unmapObject( &_frameData );
00095 
00096     return eq::Pipe::configExit();
00097 }
00098 
00099 void Pipe::frameStart( const uint32_t frameID, const uint32_t frameNumber )
00100 {
00101     eq::Pipe::frameStart( frameID, frameNumber );
00102 
00103     _frameData.sync( frameID );
00104     _renderer->setOrtho( _frameData.data.ortho );
00105 }
00106 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8