Equalizer 1.0

eqPixelBench/main.cpp

00001 
00002 /* Copyright (c) 2007-2010, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *
00007  * - Redistributions of source code must retain the above copyright notice, this
00008  *   list of conditions and the following disclaimer.
00009  * - Redistributions in binary form must reproduce the above copyright notice,
00010  *   this list of conditions and the following disclaimer in the documentation
00011  *   and/or other materials provided with the distribution.
00012  * - Neither the name of Eyescale Software GmbH nor the names of its
00013  *   contributors may be used to endorse or promote products derived from this
00014  *   software without specific prior written permission.
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026  * POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #include "channel.h"
00030 #include "config.h"
00031 #include "window.h"
00032 
00033 class NodeFactory : public eq::NodeFactory
00034 {
00035 public:
00036     virtual eq::Config*  createConfig( eq::ServerPtr parent )
00037         { return new eqPixelBench::Config( parent ); }
00038     virtual eq::Window* createWindow( eq::Pipe* parent )
00039         { return new eqPixelBench::Window( parent ); }
00040     virtual eq::Channel* createChannel( eq::Window* parent )
00041         { return new eqPixelBench::Channel( parent ); }
00042 };
00043 
00044 int main( int argc, char** argv )
00045 {
00046     // 1. initialization of local node
00047     NodeFactory nodeFactory;
00048     if( !eq::init( argc, argv, &nodeFactory ))
00049     {
00050         EQERROR << "Equalizer init failed" << std::endl;
00051         return EXIT_FAILURE;
00052     }
00053     
00054 
00055     eq::ClientPtr client = new eq::Client;
00056     if( !client->initLocal( argc, argv ))
00057     {
00058         EQERROR << "Can't init client" << std::endl;
00059         eq::exit();
00060         return EXIT_FAILURE;
00061     }
00062 
00063     // 2. connect to server
00064     eq::ServerPtr server = new eq::Server;
00065     if( !client->connectServer( server ))
00066     {
00067         EQERROR << "Can't open server" << std::endl;
00068         client->exitLocal();
00069         eq::exit();
00070         return EXIT_FAILURE;
00071     }
00072 
00073     // 3. choose config
00074     eq::ConfigParams configParams;
00075     eqPixelBench::Config* config = static_cast<eqPixelBench::Config*>(
00076         server->chooseConfig( configParams ));
00077     
00078     if( !config )
00079     {
00080         EQERROR << "No matching config on server" << std::endl;
00081         client->disconnectServer( server );
00082         client->exitLocal();
00083         eq::exit();
00084         return EXIT_FAILURE;
00085     }
00086 
00087     // 4. init config
00088     co::base::Clock clock;
00089 
00090     if( !config->init( 0 ))
00091     {
00092         server->releaseConfig( config );
00093         client->disconnectServer( server );
00094         client->exitLocal();
00095         eq::exit();
00096         return EXIT_FAILURE;
00097     }
00098     else if( config->getError( ))
00099         EQWARN << "Error during initialization: " << config->getError()
00100                << std::endl;
00101 
00102     EQLOG( eq::LOG_CUSTOM ) << "Config init took " << clock.getTimef() << " ms"
00103                             << std::endl;
00104 
00105     // 5. render three frames
00106     clock.reset();
00107     for( uint32_t i = 0; i < 3; ++i )
00108     {
00109         config->startFrame( 0 );
00110         config->finishAllFrames();
00111     }
00112     EQLOG( eq::LOG_CUSTOM ) << "Rendering took " << clock.getTimef() << " ms ("
00113                             << ( 1.0f / clock.getTimef() * 1000.f) << " FPS)"
00114                             << std::endl;
00115 
00116     // 6. exit config
00117     clock.reset();
00118     config->exit();
00119     EQLOG( eq::LOG_CUSTOM ) << "Exit took " << clock.getTimef() << " ms"
00120                             << std::endl;
00121 
00122     // 7. cleanup and exit
00123     server->releaseConfig( config );
00124     if( !client->disconnectServer( server ))
00125         EQERROR << "Client::disconnectServer failed" << std::endl;
00126     server = 0;
00127 
00128     client->exitLocal();
00129     client = 0;
00130 
00131     eq::exit();
00132     return EXIT_SUCCESS;
00133 }
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3