Show eqVol.cpp syntax highlighted
/* Copyright (c) 2005-2007, Stefan Eilemann <eile@equalizergraphics.com>
All rights reserved. */
#include "eqVol.h"
#include "config.h"
#include "localInitData.h"
#include <stdlib.h>
using namespace eqBase;
using namespace std;
namespace eqVol
{
Application::Application( const LocalInitData& initData )
: _initData( initData )
{}
int Application::run()
{
// 1. connect to server
RefPtr<eq::Server> server = new eq::Server;
if( !connectServer( server ))
{
EQERROR << "Can't open server" << endl;
return EXIT_FAILURE;
}
// 2. choose config
eq::ConfigParams configParams;
Config* config = static_cast<Config*>(server->chooseConfig( configParams ));
if( !config )
{
EQERROR << "No matching config on server" << endl;
disconnectServer( server );
return EXIT_FAILURE;
}
// 3. init config
eqBase::Clock clock;
config->setInitData( _initData );
if( !config->init( ))
{
EQERROR << "Config initialization failed: "
<< config->getErrorMessage() << endl;
server->releaseConfig( config );
disconnectServer( server );
return EXIT_FAILURE;
}
EQLOG( eq::LOG_CUSTOM ) << "Config init took " << clock.getTimef() << " ms"
<< endl;
// 4. run main loop
uint32_t maxFrames = _initData.getMaxFrames();
clock.reset();
while( config->isRunning( ) && maxFrames-- )
{
config->startFrame();
// config->renderData(...);
config->finishFrame();
}
const uint32_t frame = config->finishAllFrames();
const float time = clock.getTimef();
EQLOG( eq::LOG_CUSTOM ) << "Rendering took " << time << " ms (" << frame
<< " frames @ " << ( frame / time * 1000.f)
<< " FPS)" << endl;
// 5. exit config
clock.reset();
config->exit();
EQLOG( eq::LOG_CUSTOM ) << "Exit took " << clock.getTimef() << " ms" <<endl;
// 6. cleanup and exit
server->releaseConfig( config );
if( !disconnectServer( server ))
EQERROR << "Client::disconnectServer failed" << endl;
server = 0;
return EXIT_SUCCESS;
}
bool Application::clientLoop()
{
if( !_initData.isResident( )) // execute only one config run
return eq::Client::clientLoop();
// else execute client loops 'forever'
while( true ) // TODO: implement SIGHUP handler to exit?
{
if( !eq::Client::clientLoop( ))
return false;
EQINFO << "One configuration run successfully executed" << endl;
}
return true;
}
}
See more files for this project here