Equalizer 1.0

eVolve/pipe.cpp

00001 
00002 /*
00003  * Copyright (c) 2006-20010, 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     const InitData&        initData = config->getInitData();
00051     const eq::WindowSystem ws       = initData.getWindowSystem();
00052 
00053     if( ws == eq::WINDOW_SYSTEM_NONE )
00054         return eq::Pipe::selectWindowSystem();
00055     if( !supportsWindowSystem( ws ))
00056     {
00057         EQWARN << "Window system " << ws 
00058                << " not supported, using default window system" << std::endl;
00059         return eq::Pipe::selectWindowSystem();
00060     }
00061 
00062     return ws;
00063 }
00064 
00065 bool Pipe::configInit( const eq::uint128_t& initID )
00066 {
00067     if( !eq::Pipe::configInit( initID ))
00068         return false;
00069 
00070     Config*         config      = static_cast<Config*>( getConfig( ));
00071     const InitData& initData    = config->getInitData();
00072     const co::base::UUID  frameDataID = initData.getFrameDataID();
00073 
00074     const bool mapped = config->mapObject( &_frameData, frameDataID );
00075     EQASSERT( mapped );
00076 
00077     const std::string& filename = initData.getFilename();
00078     const uint32_t precision = initData.getPrecision();
00079     EQINFO << "Loading model " << filename << std::endl;
00080 
00081     _renderer = new Renderer( filename.c_str(), precision );
00082     EQASSERT( _renderer );
00083 
00084     if( !_renderer->loadHeader( initData.getBrightness(), initData.getAlpha( )))
00085     {
00086         setError( ERROR_EVOLVE_LOADMODEL_FAILED );
00087         EQWARN << getError() << ": " << filename << ".vhf" << std::endl;
00088         delete _renderer;
00089         _renderer = 0;
00090         return false;
00091     }
00092 
00093     return mapped;
00094 }
00095 
00096 bool Pipe::configExit()
00097 {
00098     delete _renderer;
00099     _renderer = 0;
00100 
00101     eq::Config* config = getConfig();
00102     config->unmapObject( &_frameData );
00103 
00104     return eq::Pipe::configExit();
00105 }
00106 
00107 void Pipe::frameStart( const eq::uint128_t& frameID, const uint32_t frameNumber )
00108 {
00109     eq::Pipe::frameStart( frameID, frameNumber );
00110     _frameData.sync( frameID );
00111 
00112     _renderer->setOrtho( _frameData.useOrtho( ));
00113 }
00114 }
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3