예제 #1
0
int main(int argc, char **argv) {
   
  try {
        // show version (-v) flag, close wm (-exit) flag...
	if(argc == 2 && !strcmp("-v", argv[1]))
		printf("clementine version 0.0.7.1 see LICENSE for details\n");
        else if(argc != 1)
		printf("\n");

        if(argc == 2 && !strcmp("-exit", argv[1]))
	        execlp("/bin/sh", "sh", "-c", "pkill clementinewm", NULL);
        else if(argc != 1)
                printf("\n");
		printf("Please use one of the options:\n");
                printf("usage: clementinewm [-v -exit]\n");                
	WindowManager wm;
	windowManager = &wm; // set global reference
	wm.eventLoop();
  } catch( const char*  e ) {
	std::cerr << "Unhandled exception: " << e << std::endl;
  }
  return 0;
}
int main(int argc, char **argv)
{
    // print version info
    if(argc == 2) {
        string param(argv[1]);
        if(param == "--version" || param == "-v") {
            cout << "Version information:" << endl;
            cout << "Graphics Application Revision: " << ERP_GIT_VERSION << endl;
            cout << "BOINC Revision: " << SVN_VERSION << endl;
            exit(0);
        }
    }

    // enable BOINC diagnostics
	// TODO: we might want to optimize this for glibc- and mingw-based stacktraces!
	boinc_init_graphics_diagnostics(BOINC_DIAG_DEFAULTS);

#ifdef __APPLE__
  setMacIcon(argv[0], MacAppIconData, sizeof(MacAppIconData));
#endif

	// choose application to be build/used
	GraphicsEngineFactory::Applications scienceApplication;
#ifdef SCIENCE_APP
	scienceApplication = GraphicsEngineFactory::SCIENCE_APP;
#else
	scienceApplication = GraphicsEngineFactory::EinsteinS5R3;
#endif

	// prepare main objects
	WindowManager window;
	ResourceFactory factory;
	AbstractGraphicsEngine *graphics = GraphicsEngineFactory::createInstance(
											GraphicsEngineFactory::Starsphere,
											scienceApplication);

	if(!graphics) {
		cerr << "Requested graphics engine could not be found/instantiated!" << endl;
		exit(1);
	}

    // initialize window manager
    if(!window.initialize()) {
    	cerr << "Window manager could not be initialized!" << endl;
    	delete graphics;
        exit(1);
    }

	// create font and icon resource instances
	const Resource *fontResource = factory.createInstance("FontSansSerif");
	const Resource *iconResource = factory.createInstance("AppIconBMP");

	if(fontResource == NULL) {
		cerr << "Font resource could not be loaded!" << endl;
		delete graphics;
		exit(1);
	}

	if(fontResource->data()->size() <= 0) {
		cerr << "Font resource could not be loaded!" << endl;
		delete graphics;
		delete fontResource;
		exit(1);
	}

	if(iconResource != NULL && iconResource->data()->size() > 0) {
		window.setWindowIcon(&iconResource->data()->at(0), iconResource->data()->size());
		delete iconResource;
	}
	else {
		cerr << "Icon resource could not be loaded! Continuing anyway..." << endl;
	}

    window.setWindowCaption("Einstein@Home");

    // register starsphere as event observer
    window.registerEventObserver(graphics);

	// pepare rendering
	graphics->initialize(window.windowWidth(), window.windowHeight(), fontResource);
	graphics->refreshBOINCInformation();

	// check optional command line parameters
	if(argc == 2) {
		string param(argv[1]);
		if(param == "--fullscreen") {
			// set non-interactive mode (must do this first on Apple)
			window.setScreensaverMode(true);
		}
		if(param == "--fullscreen" || param == "--demo") {
			// switch to fullscreen (on windoze: after init!)
			window.toggleFullscreen();
#ifdef __APPLE__
			SetMacSSLevel();
#endif
		}
	}

	// enter main event loop
	window.eventLoop();

	// clean up end exit
	window.unregisterEventObserver(graphics);
	delete graphics;
	delete fontResource;

	exit(0);
}