examples/eqNBody/window.cpp

00001 /*
00002  * Copyright (c) 2009, Philippe Robert <probert@eyescale.ch> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #include "window.h"
00019 
00020 #include "pipe.h"
00021 #include "config.h"
00022 #include "configEvent.h"
00023 #include "frameData.h"
00024 
00025 #include <fstream>
00026 #include <sstream>
00027 
00028 using namespace std;
00029 
00030 namespace eqNbody
00031 {       
00032     bool Window::configInit( const uint32_t initID )
00033     {
00034         // Determine window mode (and offset)
00035         const string& name = getName();
00036         size_t sepos = name.find(":");
00037 
00038         EQASSERT(sepos != string::npos);
00039 
00040         std::string tname = name.substr(0,sepos);
00041 
00042         if(tname == "CUDA") {
00043             _mode = WINDOW_CUDA;
00044         }
00045         else if(tname == "CUDA_GL") {
00046             _mode = WINDOW_CUDA_GL;
00047         }
00048         else {
00049             EQWARN << "Unhandled Window type '" << tname << "'" << std::endl;
00050             return false;
00051         }
00052         
00053         // Determine CUDA device
00054         Pipe* pipe = static_cast<Pipe*>(getPipe());
00055         _device = pipe->getDevice();
00056         
00057         if( !eq::Window::configInit( initID )) {
00058             return false;
00059         }
00060         
00061         return true;
00062     }
00063                 
00064     void Window::swapBuffers()
00065     {
00066         const Pipe*              pipe      = static_cast<Pipe*>( getPipe( ));
00067         const FrameData&         frameData = pipe->getFrameData();
00068         const eq::ChannelVector& channels  = getChannels();
00069         
00070         if( frameData.useStatistics() && !channels.empty( ))
00071             EQ_GL_CALL( channels.back()->drawStatistics( ));
00072         
00073         eq::Window::swapBuffers();
00074     }       
00075 }
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8