Example #1
0
void OgreSetup::parseWindowGeometry(Ogre::ConfigOptionMap& config, unsigned int& width, unsigned int& height, bool& fullscreen) {
	auto opt = config.find("Video Mode");
	if (opt != config.end()) {
		Ogre::String val = opt->second.currentValue;
		Ogre::String::size_type pos = val.find('x');
		if (pos != Ogre::String::npos) {

			width = Ogre::StringConverter::parseUnsignedInt(val.substr(0, pos));
			height = Ogre::StringConverter::parseUnsignedInt(val.substr(pos + 1));
		}
	}

	//now on to whether we should use fullscreen
	opt = config.find("Full Screen");
	if (opt != config.end()) {
		fullscreen = (opt->second.currentValue == "Yes");
	}

}
bool OgreFramework::initOgre(Ogre::String wndTitle, HWND hwnd)
{
    if (!hwnd)
    {
        return false;
    }

    _hWnd = hwnd;

#if _DEBUG
    m_pRoot = new Ogre::Root("plugins_d.cfg", "Ogre.cfg");
#else
    m_pRoot = new Ogre::Root("plugins.cfg", "Ogre.cfg");
#endif

//#if _DEBUG
//
//	m_pRoot->loadPlugin("RenderSystem_Direct3D9_d");
//	m_pRoot->loadPlugin("Plugin_ParticleFX_d");
//	//m_pRoot->loadPlugin("Plugin_CgProgramManager_d");
//
//#else
//
//	m_pRoot->loadPlugin("RenderSystem_Direct3D9");
//	m_pRoot->loadPlugin("Plugin_ParticleFX");
//	//m_pRoot->loadPlugin("Plugin_CgProgramManager");
//
//#endif

    if (!m_pRoot->restoreConfig())
    {
        //m_pRoot->showConfigDialog();

        RenderSystemList rList = m_pRoot->getAvailableRenderers();
        if (rList.size() == 0)
            return false;

        m_pRoot->setRenderSystem( *(rList.begin()) );

        try
        {
            m_pRoot->saveConfig();	//crash on windows vista or above if no administrator right
        }
        catch (...)
        {

        }
    }

    m_pRenderWnd = m_pRoot->initialise(false, wndTitle);

    Ogre::ConfigOptionMap	optionMap = m_pRoot->getRenderSystem()->getConfigOptions();
    if (optionMap.find("FSAA") != optionMap.end())
    {
        _strFSAA = optionMap["FSAA"].currentValue;
    }

    NameValuePairList opts;
    opts["externalWindowHandle"] = StringConverter::toString((Ogre::uint)_hWnd);
    //opts["vsync"]	= "true";
    opts["FSAA"]	= _strFSAA;

    m_pRenderWnd = m_pRoot->createRenderWindow(
                       wndTitle,
                       800, 600,
                       false, &opts
                   );


    m_pSceneMgr = m_pRoot->createSceneManager(ST_GENERIC, "SceneManager");
    m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));


    m_pCamera = m_pSceneMgr->createCamera("Camera");
    m_pCamera->setPosition(Vector3(0, 120, 120));
    m_pCamera->lookAt(Vector3(0, 0, 0));
    m_pCamera->setNearClipDistance(1);

    _pCameraController = new CameraController(m_pCamera);


    m_pViewport = m_pRenderWnd->addViewport(m_pCamera);
    m_pViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
    m_pCamera->setAspectRatio(Real(m_pViewport->getActualWidth()) / Real(m_pViewport->getActualHeight()));
    m_pViewport->setCamera(m_pCamera);


    OIS::ParamList paramList;
    unsigned long hWnd = (unsigned long)AfxGetMainWnd()->GetSafeHwnd();
    //m_pRenderWnd->getCustomAttribute("WINDOW", &hWnd);
    paramList.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
    paramList.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_FOREGROUND"));
    paramList.insert(OIS::ParamList::value_type("w32_mouse", "DISCL_NONEXCLUSIVE"));
    paramList.insert(OIS::ParamList::value_type("w32_keyboard", "DISCL_FOREGROUND"));
    paramList.insert(OIS::ParamList::value_type("w32_keyboard", "DISCL_NONEXCLUSIVE"));
    m_pInputMgr = OIS::InputManager::createInputSystem(paramList);


    m_pKeyboard = static_cast<OIS::Keyboard*>(m_pInputMgr->createInputObject(OIS::OISKeyboard, true));
    m_pKeyboard->setEventCallback(this);

    m_pMouse	= static_cast<OIS::Mouse*>(m_pInputMgr->createInputObject(OIS::OISMouse, true));
    m_pMouse->setEventCallback(this);

    m_pMouse->getMouseState().height = m_pRenderWnd->getHeight();
    m_pMouse->getMouseState().width	 = m_pRenderWnd->getWidth();

    Ogre::String secName, typeName, archName;
    Ogre::ConfigFile cf;
    cf.load("resources.cfg");

    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
        }
    }
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    m_pTimer = new Ogre::Timer();
    m_pTimer->reset();

    m_pTrayMgr = new OgreBites::SdkTrayManager("TrayMgr", m_pRenderWnd, m_pMouse, this);
    //m_pTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    //m_pTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    m_pTrayMgr->hideCursor();

    m_pRenderWnd->setActive(true);


    /*
    BaseProperty *pProp = GetClassRTTI()->GetPropertyByName("FSAA");
    Ogre::ConfigOptionMap	optionMap = m_pRoot->getRenderSystem()->getConfigOptions();
    Ogre::StringVector		fsaaVector = optionMap["FSAA"].possibleValues;
    Ogre::String			strOpts;
    for (size_t t = 0; t < fsaaVector.size(); ++t)
    {
    	strOpts += fsaaVector[t];

    	if (t != fsaaVector.size() - 1)
    	{
    		strOpts += ";";
    	}
    }
    pProp->SetValueSpecify(eValueList, strOpts);
    */


    return true;
}
Example #3
0
void App::initOgre()
{
	// Config file class is an utility that parses and stores values from a .cfg file
	Ogre::ConfigFile cf;
	std::string configFilePathPrefix = "cfg/";			// configuration files default location when app is installed
#ifdef _DEBUG
	std::string pluginsFileName = "plugins_d.cfg";		// plugins config file name (Debug mode)
#else
	std::string pluginsFileName = "plugins.cfg";		// plugins config file name (Release mode)
#endif
	std::string resourcesFileName = "resources.cfg";	// resources config file name (Debug/Release mode)


	// LOAD OGRE PLUGINS
	// Try to load load up a valid config file (and don't start the program if none is found)
	try
	{
		//This will work ONLY when application is installed (only Release application)!
		cf.load(configFilePathPrefix + pluginsFileName);
	}
	catch (Ogre::FileNotFoundException &e)
	{
		try
		{
			// if no existing config, or could not restore it, try to load from a different location
			configFilePathPrefix = "../cfg/";

			//This will work ONLY when application is in development (Debug/Release configuration)
			cf.load(configFilePathPrefix + pluginsFileName);			
		}
		catch (Ogre::FileNotFoundException &e)
		{
			// launch exception if no valid config file is found! - PROGRAM WON'T START!
			throw e;
		}
	}


	// INSTANCIATE OGRE ROOT (IT INSTANCIATES ALSO ALL OTHER OGRE COMPONENTS)
	// In Ogre, the singletons are instanciated explicitly (with new) the first time,
	// then it can be accessed with Ogre::Root::getSingleton()
	// Plugins are passed as argument to the "Root" constructor
	mRoot = new Ogre::Root(configFilePathPrefix + pluginsFileName, configFilePathPrefix + "ogre.cfg", "ogre.log");
	// No Ogre::FileNotFoundException is thrown by this, that's why we tried to open it first with ConfigFile::load()

	
	// LOAD OGRE RESOURCES
	// Load up resources according to resources.cfg ("cf" variable is reused)
	try
	{
		//This will work ONLY when application is installed!
		cf.load("cfg/resources.cfg");
	}
	catch (Ogre::FileNotFoundException &e)	// It works, no need to change anything
	{
		try
		{
			//This will work ONLY when application is in development (Debug/Release configuration)
			cf.load("../cfg/resources.cfg");
		}
		catch (Ogre::FileNotFoundException &e)
		{
			// launch exception if no valid config file is found! - PROGRAM WON'T START!
			throw e;
		}
	}

    // Go through all sections & settings in the file
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
			//For each section/key-value, add a resource to ResourceGroupManager
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
	}


	// Then setup THIS CLASS INSTANCE as a frame listener
	// This means that Ogre will call frameStarted(), frameRenderingQueued() and frameEnded()
	// automatically and periodically if defined in this class
	mRoot->addFrameListener(this);


	// SELECT AND CUSTOMIZE OGRE RENDERING (OpenGL)
	// Get a reference of the RenderSystem in Ogre that I want to customize
	Ogre::RenderSystem* pRS = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
	// Get current config RenderSystem options in a ConfigOptionMap
	Ogre::ConfigOptionMap cfgMap = pRS->getConfigOptions();
	// Modify them
	cfgMap["Full Screen"].currentValue = "No";
	cfgMap["VSync"].currentValue = "Yes";
	#ifdef _DEBUG
		cfgMap["FSAA"].currentValue = "0";
	#else
		cfgMap["FSAA"].currentValue = "8";
	#endif
	cfgMap["Video Mode"].currentValue = "1200 x 800";
	// Set them back into the RenderSystem
	for(Ogre::ConfigOptionMap::iterator iter = cfgMap.begin(); iter != cfgMap.end(); iter++) pRS->setConfigOption(iter->first, iter->second.currentValue);
	// Set this RenderSystem as the one I want to use
	mRoot->setRenderSystem(pRS);
	// Initialize it: "false" is DO NOT CREATE A WINDOW FOR ME
	mRoot->initialise(false, "Oculus Rift Visualization");


	// CREATE WINDOWS
	/* REMOVED: Rift class creates the window if no null is passed to its constructor
	// Options for Window 1 (rendering window)
	Ogre::NameValuePairList miscParams;
	if( NO_RIFT )
		miscParams["monitorIndex"] = Ogre::StringConverter::toString(0);
	else
		miscParams["monitorIndex"] = Ogre::StringConverter::toString(1);
	miscParams["border "] = "none";
	*/

	/*
	// Create Window 1
	if( !ROTATE_VIEW )
	mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1280, 800, true, &miscParams);
	//mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1920*0.5, 1080*0.5, false, &miscParams);
	else
	mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1080, 1920, true, &miscParams);
	*/

	// Options for Window 2 (debug window)
	// This window will simply show what the two cameras see in two different viewports
	Ogre::NameValuePairList miscParamsSmall;
	miscParamsSmall["monitorIndex"] = Ogre::StringConverter::toString(0);

	// Create Window 2
	if( DEBUG_WINDOW )
		mSmallWindow = mRoot->createRenderWindow("DEBUG Oculus Rift Liver Visualization", 1920*debugWindowSize, 1080*debugWindowSize, false, &miscParamsSmall);   

	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
Example #4
0
void App::initOgre()
{
#ifdef _DEBUG
    mRoot = new Ogre::Root("plugins_d.cfg");
#else
    mRoot = new Ogre::Root("plugins.cfg");
#endif
    mRoot->addFrameListener(this);

    // Load up resources according to resources.cfg:
    Ogre::ConfigFile cf;
    cf.load("resources.cfg");

    // Go through all sections & settings in the file
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
    }

    Ogre::RenderSystem* pRS = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
    Ogre::ConfigOptionMap cfgMap = pRS->getConfigOptions();
    cfgMap["Full Screen"].currentValue = "No";
    cfgMap["VSync"].currentValue = "Yes";
#ifdef _DEBUG
    cfgMap["FSAA"].currentValue = "0";
#else
    cfgMap["FSAA"].currentValue = "8";
#endif
    cfgMap["Video Mode"].currentValue = "1200 x 800";
    for(Ogre::ConfigOptionMap::iterator iter = cfgMap.begin(); iter != cfgMap.end(); iter++) pRS->setConfigOption(iter->first, iter->second.currentValue);
    mRoot->setRenderSystem(pRS);
    mRoot->initialise(false, "Oculus Rift Visualization");

    // Create the Windows:
    Ogre::NameValuePairList miscParams;
    if( NO_RIFT )
        miscParams["monitorIndex"] = Ogre::StringConverter::toString(0);
    else
        miscParams["monitorIndex"] = Ogre::StringConverter::toString(1);
    miscParams["border "] = "none";

    Ogre::NameValuePairList miscParamsSmall;
    miscParamsSmall["monitorIndex"] = Ogre::StringConverter::toString(0);

    if( !ROTATE_VIEW )
        mWindow = mRoot->createRenderWindow("ShowARoom", WIDTH, HEIGHT, FULL_SCREEN, &miscParams);
    //mWindow = mRoot->createRenderWindow("Oculus Rift Liver Visualization", 1920*0.5, 1080*0.5, false, &miscParams);
    else
        mWindow = mRoot->createRenderWindow("ShowARoom", HEIGHT, WIDTH, FULL_SCREEN, &miscParams);

    if( DEBUG_WINDOW )
        mSmallWindow = mRoot->createRenderWindow("DEBUG ShowARoom", 1920*debugWindowSize, 1080*debugWindowSize, false, &miscParamsSmall);

    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
Example #5
0
/*!
  Initialisation of Ogre.

  Load the plugins that are specified in the plugins.cfg or
  plugins_d.cfg files. These files are located in
  VISP_HAVE_OGRE_PLUGINS_PATH folder that is defined in vpConfig.h.
  Note that plugins.cfg file is always considered under Unix
  platforms. The file plugins_d.cfg is only considered under Windows
  when the build type is Debug.

  Load also the resources that are defined in the resources.cfg
  file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder
  that is defined in vpConfig.h.

  \param bufferedKeys : If true, use of buffered input for the keyboard (see
  Ogre documentation). Note that this parameter is only useful if OIS is used.

  \param hidden : If true, the created window will be hidden.
  Note that this functionnality requires Ogre3D 1.8.1 at least.

  \exception vpException::ioError : If the required plugins.cfg /
  plugins_d.cfg or resources.cfg files are not accessible.

*/
void vpAROgre::init(bool
#ifdef VISP_HAVE_OIS
		    bufferedKeys
#endif
        ,bool hidden
		    )
{
  // Create the root
  // mPluginsPath may contain more than one folder location separated by ";"
  bool pluginsFileExists = false;
  std::string pluginFile;
  std::vector<std::string> plugingsPaths = vpIoTools::splitChain(std::string(mPluginsPath), std::string(";"));
  for (size_t i=0; i<plugingsPaths.size(); i++) {
#if defined(NDEBUG) || !defined(_WIN32)
    pluginFile = plugingsPaths[i]+"/plugins.cfg";
#else
    pluginFile = plugingsPaths[i]+"/plugins_d.cfg";
#endif

    if(vpIoTools::checkFilename(pluginFile)) {
      pluginsFileExists = true;
      break;
    }
  }
  if (! pluginsFileExists) {
    std::string errorMsg = std::string("Error: the requested plugins file \"")
#if defined(NDEBUG) || !defined(_WIN32)
        + std::string("plugins.cfg")
#else
        + std::string("plugins_d.cfg")
#endif
    + std::string("\" doesn't exist in ")
    + std::string(mPluginsPath);
    std::cout << errorMsg << std::endl;

    throw (vpException(vpException::ioError, errorMsg));
  }
  std::cout << "######################### Load plugin file: " << pluginFile << std::endl;

  if(Ogre::Root::getSingletonPtr() == NULL)
    mRoot = new Ogre::Root(pluginFile, "ogre.cfg", "Ogre.log");
  else
    mRoot = Ogre::Root::getSingletonPtr();

  // Load resource paths from config file

  // File format is:
  //  [ResourceGroupName]
  //  ArchiveType=Path
  //  .. repeat
  // For example:
  //  [General]
  //  FileSystem=media/
  //  Zip=packages/level1.zip

  // mResourcePath may contain more than one folder location separated by ";"
  bool resourcesFileExists = false;
  std::string resourceFile;
  std::vector<std::string> resourcesPaths = vpIoTools::splitChain(std::string(mResourcePath), std::string(";"));
  for (size_t i=0; i<resourcesPaths.size(); i++) {
    resourceFile = resourcesPaths[i]+"/resources.cfg";
    if(vpIoTools::checkFilename(resourceFile)) {
      resourcesFileExists = true;
      break;
    }
  }
  if (! resourcesFileExists) {
    std::string errorMsg = std::string("Error: the requested resource file \"resources.cfg\"")
        + std::string("doesn't exist in ")
        + std::string(mResourcePath);

    std::cout << errorMsg << std::endl;

    throw (vpException(vpException::ioError, errorMsg));
  }
  std::cout << "######################### Load resource file: " << resourceFile << std::endl;
  Ogre::ConfigFile cf;
  cf.load(resourceFile);

  // Go through all sections & settings in the file
  Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

  Ogre::String secName, typeName, archName;
  while (seci.hasMoreElements())
    {
      secName = seci.peekNextKey();
      Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
      Ogre::ConfigFile::SettingsMultiMap::iterator i;
      for (i = settings->begin(); i != settings->end(); ++i)
	{
	  typeName = i->first;
	  archName = i->second;
	  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
									 archName, typeName, secName);
	}
    }
    std::cout << "##################### add resources" << std::endl;
  //Add optionnal resources (given by the user).
  for(std::list<std::string>::const_iterator iter = mOptionnalResourceLocation.begin(); iter != mOptionnalResourceLocation.end(); ++iter){
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(*iter, "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
  }

  // Create the window
  bool canInit = true;
  if(mshowConfigDialog){
    mRoot->restoreConfig();
    if(!mRoot->showConfigDialog())
      canInit = false;
  }
  else{
    if(!mRoot->restoreConfig())
      canInit = false;
  }

  if(!mRoot->isInitialised()){
    if(!canInit){ //We set the default renderer system
      const Ogre::RenderSystemList& lRenderSystemList = mRoot->getAvailableRenderers();
      if( lRenderSystemList.size() == 0 )
        throw "ConfigDialog aborted"; // Exit the application on cancel

      Ogre::RenderSystem *lRenderSystem = lRenderSystemList.at(0);
      std::cout << "Using " << lRenderSystem->getName() << " as renderer." << std::endl;
      mRoot->setRenderSystem(lRenderSystem);
    }

    mRoot->initialise(false);
  }

  bool fullscreen = false;
  Ogre::NameValuePairList misc;
  Ogre::ConfigOptionMap config = mRoot->getRenderSystem()->getConfigOptions();
  Ogre::ConfigOptionMap::const_iterator it = config.begin();

  while( it != config.end() ){
    Ogre::String leftconf = (*it).first;
    Ogre::String rightconf = (*it).second.currentValue;

    if(leftconf == "Video Mode"){
      if(canInit) {
        int ret = sscanf(rightconf.c_str(), "%d %*s %d", &mWindowWidth, &mWindowHeight);
        if (ret == 0)
          std::cout << "Cannot read Ogre video mode" << std::endl;
      }
      else{
        if(mWindowWidth == 0 && mWindowHeight == 0){
          mWindowWidth = mBackgroundWidth;
          mWindowHeight = mBackgroundHeight;
        }
      }
    }
    else if( leftconf == "Full Screen" ){
      if(canInit){
        if(rightconf == "Yes") fullscreen = true;
      }
    }
    else
      misc[leftconf] = rightconf;

    it++;
  }

  // With Ogre version >= 1.8.1 we hide the window
  if( hidden ){
#if ( OGRE_VERSION >= (1 << 16 | 8 << 8 | 1) )
    misc["hidden"] = "true";
    windowHidden = true;
#endif
  }
  mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc);

  // Initialise resources
  Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
  //-----------------------------------------------------
  // 4 Create the SceneManager
  //
  //		ST_GENERIC = octree
  //		ST_EXTERIOR_CLOSE = simple terrain
  //		ST_EXTERIOR_FAR = nature terrain (depreciated)
  //		ST_EXTERIOR_REAL_FAR = paging landscape
  //		ST_INTERIOR = Quake3 BSP
  //-----------------------------------------------------

  mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);

  // Create the camera
  createCamera();

  // Create a viewport
  Ogre::Viewport* viewPort = mWindow->addViewport(mCamera);
//   Ogre::Viewport* viewPort = mCamera->getViewport();
  viewPort->setClearEveryFrame(true);
  // Set the projection parameters to match the camera intrinsic parameters
  updateCameraProjection();

  // Create the 3D scene
  createScene();

  // Initialise and register event handlers
  mRoot->addFrameListener(this);

  // Register as a Window listener
  Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

#ifdef VISP_HAVE_OIS
  // Initialise OIS
  Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
  OIS::ParamList pl;

  size_t windowHnd = 0;
  std::ostringstream windowHndStr;
  // Initialise window
  mWindow->getCustomAttribute("WINDOW", &windowHnd);
  windowHndStr << windowHnd;
  pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
  // Let the user use the keyboard elsewhere
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
  pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
#endif

  mInputManager = OIS::InputManager::createInputSystem( pl );

  //Create all devices
  // Here we only consider the keyboard input
  mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, bufferedKeys ));
  if ( !bufferedKeys ) mKeyboard->setEventCallback ( this);
#endif

  // Initialise a render to texture to be able to retrieve a screenshot
  Ogre::TexturePtr Texture = Ogre::TextureManager::getSingleton().createManual("rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,Ogre::TEX_TYPE_2D,
                                                                               mWindow->getWidth(),mWindow->getHeight(), 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET);



//   Ogre::TexturePtr Texture = Ogre::TextureManager::getSingleton().createManual("rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,Ogre::TEX_TYPE_2D,
//                                                                                640,480, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET);
  Ogre::RenderTexture* RTarget = Texture->getBuffer()->getRenderTarget();
  /*Ogre::Viewport* Viewport =*/ RTarget->addViewport(mCamera);
  RTarget->getViewport(0)->setClearEveryFrame(true);
  RTarget->getViewport(0)->setOverlaysEnabled(false);
}