eqPixelBench/main.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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
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
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
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
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
00107 clock.reset();
00108 config->exit();
00109 EQLOG( eq::LOG_CUSTOM ) << "Exit took " << clock.getTimef() << " ms" <<endl;
00110
00111
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 }