Пример #1
0
    Application::Application( int& argc, char** argv, GameLogic* gameLogic )
        : QApplication( argc, argv )
        , mOpenGLRenderSystem( 0 )
        , mDirect3D9RenderSystem( 0 )
        , mFrameCounter( 0 )
    {
        mGameLogic = gameLogic;
        if( mGameLogic != 0 )
        {
            mGameLogic->mApplication = this;
        }

        //Initialise the resources.
        initQtResources();

        //Load the settings file. If it doesn't exist it is created.
        mSettings = new QSettings( "settings.ini", QSettings::IniFormat );

        mOgreWidget = new EventHandlingOgreWidget( 0, 0 );

        //Logging should be initialised ASAP, and before Ogre::Root is created.
        initialiseLogging();

        //Create the root and load render system plugins. We do that here so that we know
        //what render systems are available by the time we show the settings dialog.
        //Note that the render system is not initialised until the user selects one.
        mRoot = new Ogre::Root();
        loadRenderSystemsFromPlugins();

        mSettingsDialog = new SettingsDialog( mSettings, mOgreWidget );
        mGraphicsSettingsWidget = new GraphicsSettingsWidget;
        mSettingsDialog->addSettingsWidget( "Graphics", mGraphicsSettingsWidget );
    }
Пример #2
0
OgreSys::OgreSys()
:mInternalOgreLog(0)
,mInternalOgreLogManager(0)
,mActiveRenderSystem(0)
,mOpenGLRenderSystem(0)
,mDirect3D9RenderSystem(0)
,mRoot(0)
,mFrameCounter(0)
{
	initialiseLogging();

	try
	{
#ifdef QT_DEBUG
		mRoot = new Ogre::Root("plugins_d.cfg");
#else
		mRoot = new Ogre::Root("plugins.cfg");
#endif
		qDebug("Ogre::Root created successfully.");
	}
	catch(Ogre::Exception& e)
	{
		QString error
			(
			"Failed to create the Ogre::Root object. This is a fatal error and the "
			"application will now exit. There are a few known reasons why this can occur:\n\n"
			"    1) Ensure your plugins.cfg has the correct path to the plugins.\n"
			"    2) In plugins.cfg, use unix style directorary serperators. I.e '/' rather than '\\'.\n"
			"    3) If your plugins.cfg is trying to load the Direct3D plugin, make sure you have DirectX installed on your machine.\n\n"
			"The message returned by Ogre was:\n\n"
			);
		error += QString::fromStdString(e.getFullDescription().c_str());

		//Not much else we can do here...
		std::exit(1);
	}

	//Load the render system plugins. We do that here so that we know what
	//render systems are available by the time we show the settings dialog.
	//Note that the render system is not initialised until the user selects one.
	mOpenGLRenderSystem = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
	mDirect3D9RenderSystem = mRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
	if(!(mOpenGLRenderSystem || mDirect3D9RenderSystem))
	{
	}
}
Пример #3
0
    po::variables_map initProgramOptions(int argc, char* argv[], const po::options_description& cmdLineOptions)
    {
      // Create the global options object
      po::options_description cmdLine("Command-Line Options");

      // Create the generic config options for all GDF apps
      cmdLine.add(genericCommandLineOptions());
      // Add the other options specifically defined
      cmdLine.add(cmdLineOptions);

      // Parse the command line 
      po::variables_map vm;
      try
      {
        po::store(po::parse_command_line(argc, argv, cmdLine), vm);
        po::notify(vm);
      } catch (const std::exception& ex)
      {
        std::cout << "Error: Unrecognised commandline arguments\n\n" << cmdLine << "\n";
        exit(EXIT_FAILURE);
      }

      // Act on the generic options
      if (vm.count("version"))
      {
        std::cout << "Version 0.1\n";
        exit(EXIT_SUCCESS);
      }
      if (vm.count("help"))
      {
        std::cout << cmdLine << "\n";
        exit(EXIT_SUCCESS);
      }
      // Initialise logging
      bool silent = vm.count("silent");
      initialiseLogging(argv[0], vm["loglevel"].as<int>(), !silent, vm["logdir"].as<std::string>());
      return vm;
    }
Пример #4
0
	Application::Application(int& argc, char** argv, GameLogic* gameLogic, IgnoredConfigWarningMode ignoredConfigWarningMode)
	:QApplication(argc, argv)
	,mFPSDialog(0)
	,mGraphicsSettingsWidget(0)
	,mOgreWidget(0)
	,mSettingsDialog(0)
	,mInternalOgreLog(0)
	,mInternalOgreLogManager(0)
	,mLogManager(0)
	,mOgreLog(0)
	,mSystemLog(0)
	,mActiveRenderSystem(0)
	,mOpenGLRenderSystem(0)
	,mDirect3D9RenderSystem(0)
	,mRoot(0)
	,mFrameCounter(0)
	,mGameLogic(gameLogic)
	,mAutoUpdateTimer(0)
	,mSettings(0)
	,mAutoUpdateEnabled(true)
	,mIsInitialised(false)
	,mIgnoredConfigWarningMode(ignoredConfigWarningMode)
	{
		if(mGameLogic != 0)
		{
			mGameLogic->mApplication = this;
		}

		//Initialise the resources.
		initQtResources();

		//Sanity check for config files
		if(mIgnoredConfigWarningMode == WarnAboutIgnoredConfigs)
		{
			QDirIterator it(".");
			while (it.hasNext())
			{
				it.next();
				if(QString::compare(it.fileInfo().suffix(), "cfg", Qt::CaseInsensitive) == 0)
				{
					if(	(QString::compare(it.fileInfo().baseName(), "plugins", Qt::CaseInsensitive) != 0) &&
						(QString::compare(it.fileInfo().baseName(), "plugins_d", Qt::CaseInsensitive) != 0) &&
						(QString::compare(it.fileInfo().baseName(), "resources", Qt::CaseInsensitive) != 0))
					{
						//We have found a file with the .cfg extension but which is not
						//'plugins.cfg' or 'resources.cfg'. Warn the user about this.
						warnAboutIgnoredConfigFile(it.fileInfo().fileName());
					}
				}
			}
		}

		mAutoUpdateTimer = new QTimer;
		QObject::connect(mAutoUpdateTimer, SIGNAL(timeout()), this, SLOT(update()));
		//On the test system, a value of one here gives a high frame rate and still allows
		//event processing to take place. A value of 0 doubles the frame rate but the mouse
		//becomes jumpy. This property is configerable via setAutoUpdateInterval().
		mAutoUpdateTimer->setInterval(1);

		//Load the settings file. If it doesn't exist it is created.
		mSettings = new QSettings("settings.ini", QSettings::IniFormat);

		mOgreWidget = new EventHandlingOgreWidget(0, 0);

		//Logging should be initialised ASAP, and before Ogre::Root is created.
		initialiseLogging();

		//Create the Ogre::Root object.
		qDebug("Creating Ogre::Root object...");
		try
		{
#ifdef QT_DEBUG
			mRoot = new Ogre::Root("plugins_d.cfg");
#else
			mRoot = new Ogre::Root("plugins.cfg");
#endif
			qDebug("Ogre::Root created successfully.");
		}
		catch(Ogre::Exception& e)
		{
			QString error
				(
				"Failed to create the Ogre::Root object. This is a fatal error and the "
				"application will now exit. There are a few known reasons why this can occur:\n\n"
				"    1) Ensure your plugins.cfg has the correct path to the plugins.\n"
				"    2) In plugins.cfg, use unix style directorary serperators. I.e '/' rather than '\\'.\n"
				"    3) If your plugins.cfg is trying to load the Direct3D plugin, make sure you have DirectX installed on your machine.\n\n"
				"The message returned by Ogre was:\n\n"
				);
			error += QString::fromStdString(e.getFullDescription().c_str());

			qCritical(error.toAscii());
			showErrorMessageBox(error);

			//Not much else we can do here...
			std::exit(1);
		}

		//Load the render system plugins. We do that here so that we know what
		//render systems are available by the time we show the settings dialog.
		//Note that the render system is not initialised until the user selects one.
		mOpenGLRenderSystem = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
		mDirect3D9RenderSystem = mRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
		if(!(mOpenGLRenderSystem || mDirect3D9RenderSystem))
		{
			qCritical("No rendering subsystems found");
			showErrorMessageBox("No rendering subsystems found. Please ensure that your 'plugins.cfg' (or 'plugins_d.cfg') is correct and can be found by the executable.");
		}

		mSettingsDialog = new SettingsDialog(mSettings, mOgreWidget);
		mGraphicsSettingsWidget = new GraphicsSettingsWidget;
		mSettingsDialog->addSettingsWidget("Graphics", mGraphicsSettingsWidget);
	}