eqPixelBench/main.cpp

00001 
00002 /* Copyright (c) 2007-2008, Stefan Eilemann <eile@equalizergraphics.com> 
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 "channel.h"
00019 #include "config.h"
00020 #include "window.h"
00021 
00022 using namespace std;
00023 using namespace eq::base;
00024 
00025 class NodeFactory : public eq::NodeFactory
00026 {
00027 public:
00028     virtual eq::Config*  createConfig( eq::ServerPtr parent )
00029         { return new eqPixelBench::Config( parent ); }
00030     virtual eq::Window* createWindow( eq::Pipe* parent )
00031         { return new eqPixelBench::Window( parent ); }
00032     virtual eq::Channel* createChannel( eq::Window* parent )
00033         { return new eqPixelBench::Channel( parent ); }
00034 };
00035 
00036 int main( int argc, char** argv )
00037 {
00038     // 1. initialization of local node
00039     NodeFactory nodeFactory;
00040     if( !eq::init( argc, argv, &nodeFactory ))
00041     {
00042         EQERROR << "Equalizer init failed" << endl;
00043         return EXIT_FAILURE;
00044     }
00045 
00046     RefPtr<eq::Client> client = new eq::Client;
00047     if( !client->initLocal( argc, argv ))
00048     {
00049         EQERROR << "Can't init client" << endl;
00050         eq::exit();
00051         return EXIT_FAILURE;
00052     }
00053 
00054     // 2. connect to server
00055     RefPtr<eq::Server> server = new eq::Server;
00056     if( !client->connectServer( server ))
00057     {
00058         EQERROR << "Can't open server" << endl;
00059         client->exitLocal();
00060         eq::exit();
00061         return EXIT_FAILURE;
00062     }
00063 
00064     // 3. choose config
00065     eq::ConfigParams configParams;
00066     eqPixelBench::Config* config = static_cast<eqPixelBench::Config*>(
00067         server->chooseConfig( configParams ));
00068 
00069     if( !config )
00070     {
00071         EQERROR << "No matching config on server" << endl;
00072         client->disconnectServer( server );
00073         client->exitLocal();
00074         eq::exit();
00075         return EXIT_FAILURE;
00076     }
00077 
00078     // 4. init config
00079     eq::base::Clock clock;
00080 
00081     if( !config->init( 0 ))
00082     {
00083         EQERROR << "Config initialization failed: " 
00084                 << config->getErrorMessage() << endl;
00085         server->releaseConfig( config );
00086         client->disconnectServer( server );
00087         client->exitLocal();
00088         eq::exit();
00089         return EXIT_FAILURE;
00090     }
00091 
00092     EQLOG( eq::LOG_CUSTOM ) << "Config init took " << clock.getTimef() << " ms"
00093                             << endl;
00094 
00095     // 5. render three frames
00096     clock.reset();
00097     for( uint32_t i = 0; i < 3; ++i )
00098     {
00099         config->startFrame( 0 );
00100         config->finishAllFrames();
00101     }
00102     EQLOG( eq::LOG_CUSTOM ) << "Rendering took " << clock.getTimef() << " ms ("
00103                             << ( 1.0f / clock.getTimef() * 1000.f) << " FPS)"
00104                             << endl;
00105 
00106     // 6. exit config
00107     clock.reset();
00108     config->exit();
00109     EQLOG( eq::LOG_CUSTOM ) << "Exit took " << clock.getTimef() << " ms" <<endl;
00110 
00111     // 7. cleanup and exit
00112     server->releaseConfig( config );
00113     if( !client->disconnectServer( server ))
00114         EQERROR << "Client::disconnectServer failed" << endl;
00115     server = 0;
00116 
00117     client->exitLocal();
00118     client = 0;
00119 
00120     eq::exit();
00121     return EXIT_SUCCESS;
00122 }
Generated on Mon Aug 10 18:58:40 2009 for Equalizer 0.9 by  doxygen 1.5.8