Equalizer
1.4.1
|
00001 00002 /* 00003 * Copyright (c) 2006-2010, Stefan Eilemann <eile@equalizergraphics.com> 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * - Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * - Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * - Neither the name of Eyescale Software GmbH nor the names of its 00014 * contributors may be used to endorse or promote products derived from this 00015 * software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 00029 * 00030 * The pipe object is responsible for maintaining GPU-specific and 00031 * frame-specific data. The identifier passed by the application contains the 00032 * version of the frame data corresponding to the rendered frame. The pipe's 00033 * start frame callback synchronizes the thread-local instance of the frame data 00034 * to this version. 00035 */ 00036 00037 #include "pipe.h" 00038 00039 #include "config.h" 00040 #include "error.h" 00041 #include "node.h" 00042 00043 #include <eq/eq.h> 00044 00045 namespace eVolve 00046 { 00047 eq::WindowSystem Pipe::selectWindowSystem() const 00048 { 00049 const Config* config = static_cast<const Config*>( getConfig( )); 00050 return config->getInitData().getWindowSystem(); 00051 } 00052 00053 bool Pipe::configInit( const eq::uint128_t& initID ) 00054 { 00055 if( !eq::Pipe::configInit( initID )) 00056 return false; 00057 00058 Config* config = static_cast<Config*>( getConfig( )); 00059 const InitData& initData = config->getInitData(); 00060 const lunchbox::UUID frameDataID = initData.getFrameDataID(); 00061 00062 const bool mapped = config->mapObject( &_frameData, frameDataID ); 00063 LBASSERT( mapped ); 00064 00065 const std::string& filename = initData.getFilename(); 00066 const uint32_t precision = initData.getPrecision(); 00067 LBINFO << "Loading model " << filename << std::endl; 00068 00069 _renderer = new Renderer( filename.c_str(), precision ); 00070 LBASSERT( _renderer ); 00071 00072 if( !_renderer->loadHeader( initData.getBrightness(), initData.getAlpha( ))) 00073 { 00074 setError( ERROR_EVOLVE_LOADMODEL_FAILED ); 00075 LBWARN << getError() << ": " << filename << ".vhf" << std::endl; 00076 delete _renderer; 00077 _renderer = 0; 00078 return false; 00079 } 00080 00081 return mapped; 00082 } 00083 00084 bool Pipe::configExit() 00085 { 00086 delete _renderer; 00087 _renderer = 0; 00088 00089 eq::Config* config = getConfig(); 00090 config->unmapObject( &_frameData ); 00091 00092 return eq::Pipe::configExit(); 00093 } 00094 00095 void Pipe::frameStart( const eq::uint128_t& frameID, const uint32_t frameNumber ) 00096 { 00097 eq::Pipe::frameStart( frameID, frameNumber ); 00098 _frameData.sync( frameID ); 00099 00100 _renderer->setOrtho( _frameData.useOrtho( )); 00101 } 00102 }