Esempio n. 1
0
	bool CServer::configureOgre(bool force)
	{
		//////////////////
		// OGRE         //
		//////////////////

		// Carga los ajustes de configudación desde ogre.cfg
		if(force || !_root->restoreConfig()) {
			//// Si no hay archivo de configuración se lanza la ventana de configuración
			//if(!_root->showConfigDialog()) {
			//	// Si el juego no se puede configurar se finaliza
			//	return false;
			//}

			///seteamos la resolucion y el rendersystem a mano
			Ogre::RenderSystemList rs = _root->getAvailableRenderers();
			Ogre::RenderSystemList::iterator it = rs.begin();

			for(; it != rs.end(); ++it)
			{
				if((*it)->getName() == "Direct3D9 Rendering Subsystem")
				{
					_root->setRenderSystem((*it));

					(*it)->setConfigOption("Full Screen","No");  
					(*it)->setConfigOption("Video Mode","1280 x 720 @ 32-bit colour");
				}
			}
		}
		return true;

	} // configure
Esempio n. 2
0
/**
 * @brief init the object
 * @author kito berg-taylor
 */
void OgreWidget::init()
{
  // create the main ogre object
  mOgreRoot = new Ogre::Root;

  mOgreRoot->loadPlugin("RenderSystem_GL");
  Ogre::String rName("OpenGL Rendering Subsystem");
  Ogre::RenderSystemList rList = mOgreRoot->getAvailableRenderers();
  Ogre::RenderSystemList::iterator it = rList.begin();
  Ogre::RenderSystem *rSys = 0;
  while(it != rList.end())
  {
    rSys = * (it++);
    Ogre::String strx=rSys->getName();
    if(strx == rName)
    {
      mOgreRoot->setRenderSystem(rSys);
      break;
    }
  }
   QString dimensions = QString( "%1x%2" )
                    .arg(this->width())
                    .arg(this->height());
 
  rSys->setConfigOption( "Video Mode", dimensions.toStdString() );
 
  // initialize without creating window
  mOgreRoot->getRenderSystem()->setConfigOption( "Full Screen", "No" );
  mOgreRoot->saveConfig();
  mOgreRoot->initialise(false); // don't create a window
}
//------------------------------------------------------------------------------
void wxOgreRenderSystem::SelectOgreRenderSystem(const Ogre::String& render)
{
    Ogre::RenderSystemList renderList;
    Ogre::RenderSystemList::iterator it;

    renderList = m_root->getAvailableRenderers();
    // check through all available renderers, if there is one the
    // string is "render"
    for (it = renderList.begin(); it != renderList.end(); ++it) {
        Ogre::RenderSystem* renderSys = *it;
        if (std::string (renderSys->getName()) == render) {
            m_root->setRenderSystem(renderSys);
            break;
        }
    }

}
void
dmz::RenderModuleCoreOgreBasic::_init_render_system (Config &local) {

   if (_root) {

      String renderSystemName (
         config_to_string ("renderSystem.name", local, "OpenGL"));

      Ogre::RenderSystem *renderSystem (0);

      Ogre::RenderSystemList *renderSystemList = _root->getAvailableRenderers ();
      if (renderSystemList) {

         Ogre::RenderSystemList::iterator it = renderSystemList->begin ();
         while (it != renderSystemList->end () && !renderSystem) {

            if (renderSystemList->size () == 1) {

               renderSystem = *it;
            }
            else {

               Ogre::String curName ((*it)->getName ());
               if (curName.find (renderSystemName.get_buffer ()) >= 0) {

                  renderSystem = *it;
               }
            }

            it++;
         }
      }

      if (renderSystem) {

         _root->setRenderSystem (renderSystem);
         _root->initialise (false); // don't autocreate a window
      }
      else {

         _log.error
            << "Specified render system (" << renderSystemName << ") not found" << endl;
      }
   }
}
Esempio n. 5
0
  virtual void SetUp()
  {
    Ogre::LogManager* log_manager = new Ogre::LogManager();
    log_manager->createLog( "Ogre.log", false, false, true );

    g_root = new Ogre::Root();
    g_root->loadPlugin( "RenderSystem_GL" );
    g_root->loadPlugin( "Plugin_OctreeSceneManager" );

    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    // Taken from gazebo
    Ogre::RenderSystemList *rsList = g_root->getAvailableRenderers();

    Ogre::RenderSystem* render_system = NULL;
    Ogre::RenderSystemList::iterator renderIt = rsList->begin();
    Ogre::RenderSystemList::iterator renderEnd = rsList->end();
    for ( ; renderIt != renderEnd; ++renderIt )
    {
      render_system = *renderIt;

      if ( render_system->getName() == "OpenGL Rendering Subsystem" )
      {
        break;
      }
    }

    if ( render_system == NULL )
    {
      printf( "Could not find the opengl rendering subsystem!\n" );
      exit(1);
    }

    render_system->setConfigOption("Full Screen","No");
    render_system->setConfigOption("FSAA","2");
    render_system->setConfigOption("RTT Preferred Mode", "PBuffer");

    g_root->setRenderSystem( render_system );
    g_render_window = g_root->initialise( true );
    g_scene_manager = g_root->createSceneManager( Ogre::ST_GENERIC, "TestSceneManager" );
    g_viewport = g_render_window->addViewport( NULL );

    g_root->renderOneFrame();
  }
Esempio n. 6
0
void OgreWidget::initialiseOgre(void)
{
    Ogre::RenderSystem* Direct3D9RenderSystem = 0;

    try
    {
        mRoot->loadPlugin("RenderSystem_Direct3D9");
    }
    catch (...)
    {
        qWarning("Failed to load Direct3D9 plugin");
    }

    Ogre::RenderSystemList list = Ogre::Root::getSingletonPtr()->getAvailableRenderers();
    Ogre::RenderSystemList::iterator i = list.begin();

    while (i != list.end())
    {
        if ((*i)->getName() == "Direct3D9 Rendering Subsystem")
        {
            Direct3D9RenderSystem = *i;
        }
        i++;
    }

    if (!Direct3D9RenderSystem)
    {
        qCritical("No rendering subsystems found");
        exit(0);
    }

    if (Direct3D9RenderSystem != 0)
    {
        mActiveRenderSystem = Direct3D9RenderSystem;
    }

    Ogre::Root::getSingletonPtr()->setRenderSystem(mActiveRenderSystem);
    Ogre::Root::getSingletonPtr()->initialise(false);

    mRoot->addFrameListener(this);
}
Esempio n. 7
0
void CLASS::UpdateControls()
{

	int valuecounter = 0; // Going to be usefull for selections

	//Lang (Still not done)
	if (!IsLoaded)
	{
		m_lang->addItem("English (U.S.)");
	}
	m_lang->setIndexSelected(0); //TODO

	if (!IsLoaded)
	{
		m_gearbox_mode->addItem("Automatic shift");
		m_gearbox_mode->addItem("Manual shift - Auto clutch");
		m_gearbox_mode->addItem("Fully Manual: sequential shift");
		m_gearbox_mode->addItem("Fully Manual: stick shift");
		m_gearbox_mode->addItem("Fully Manual: stick shift with ranges");
	}

	//Gearbox
	Ogre::String gearbox_mode = GameSettingsMap["GearboxMode"];
	if (gearbox_mode == "Manual shift - Auto clutch")
		m_gearbox_mode->setIndexSelected(1);
	else if (gearbox_mode == "Fully Manual: sequential shift")
		m_gearbox_mode->setIndexSelected(2);
	else if (gearbox_mode == "Fully Manual: stick shift")
		m_gearbox_mode->setIndexSelected(3);
	else if (gearbox_mode == "Fully Manual: stick shift with ranges")
		m_gearbox_mode->setIndexSelected(4);
	else
		m_gearbox_mode->setIndexSelected(0);


	Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
	// add all rendersystems to the list
	if (m_render_sys->getItemCount() == 0)
	{
		const Ogre::RenderSystemList list = Application::GetOgreSubsystem()->GetOgreRoot()->getAvailableRenderers();
		int selection = 0;
		for (Ogre::RenderSystemList::const_iterator it = list.begin(); it != list.end(); it++, valuecounter++)
		{
			if (rs && rs->getName() == (*it)->getName())
			{
				ExOgreSettingsMap["Render System"] = rs->getName();
				selection = valuecounter;
			}
			else if (!rs) {
				LOG("Error: No Ogre Render System found");
			}
			if (!IsLoaded)
			{
				m_render_sys->addItem(Ogre::String((*it)->getName()));
			}
		}
		m_render_sys->setIndexSelected(selection);
	}

	Ogre::ConfigFile cfg;
	cfg.load(SSETTING("ogre.cfg", "ogre.cfg"));

	//Few GameSettingsMap
	Ogre::String bFullScreen = cfg.getSetting("Full Screen", rs->getName());
	if (bFullScreen == "Yes")
	{
		ExOgreSettingsMap["Full Screen"] = "Yes";
		m_fullscreen->setStateCheck(true);
	}
	else
	{
		ExOgreSettingsMap["Full Screen"] = "No";
		m_fullscreen->setStateCheck(false);
	}

	Ogre::String bVsync = cfg.getSetting("VSync", rs->getName());
	if (bVsync == "Yes")
	{
		ExOgreSettingsMap["VSync"] = "Yes";
		m_vsync->setStateCheck(true);
	}
	else
	{
		ExOgreSettingsMap["VSync"] = "No";
		m_vsync->setStateCheck(false);
	}
		
	// store available rendering devices and available resolutions
	Ogre::ConfigOptionMap& CurrentRendererOptions = rs->getConfigOptions();
	Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin();
	Ogre::StringVector mFoundResolutions;
	Ogre::StringVector mFoundFSAA;
	while (configItr != CurrentRendererOptions.end())
	{
		if ((configItr)->first == "Video Mode")
		{
			// Store Available Resolutions
			mFoundResolutions = ((configItr)->second.possibleValues);
		}
		if ((configItr)->first == "FSAA")
		{
			// Store Available Resolutions
			mFoundFSAA = ((configItr)->second.possibleValues);
		}
		configItr++;
	}

	//Loop thru the vector for the resolutions
	valuecounter = 0; //Back to default
	Ogre::StringVector::iterator iterRes = mFoundResolutions.begin();
	for (; iterRes != mFoundResolutions.end(); iterRes++)
	{
		if (!IsLoaded)
		{
			m_resolution->addItem(Ogre::String((iterRes)->c_str()));
		}
		if ((iterRes)->c_str() == cfg.getSetting("Video Mode", rs->getName()))
		{
			ExOgreSettingsMap["Video Mode"] = (iterRes)->c_str();
			m_resolution->setIndexSelected(valuecounter);
		}
		valuecounter++;
	}

	//Loop thru the vector for the FSAAs
	valuecounter = 0; //Back to default
	Ogre::StringVector::iterator iterFSAA = mFoundFSAA.begin();
	for (; iterFSAA != mFoundFSAA.end(); iterFSAA++)
	{
		if (!IsLoaded)
		{
			m_fsaa->addItem(Ogre::String((iterFSAA)->c_str()));
		}
		if ((iterFSAA)->c_str() == cfg.getSetting("FSAA", rs->getName()))
		{
			ExOgreSettingsMap["FSAA"] = (iterFSAA)->c_str();
			m_fsaa->setIndexSelected(valuecounter);
		}
		
		valuecounter++;
	}

	//Few GameSettingsMap
	if (GameSettingsMap["ArcadeControls"] == "Yes")
		m_arc_mode->setStateCheck(true);
	else
		m_arc_mode->setStateCheck(false);

	if (GameSettingsMap["External Camera Mode"] == "Static")
		m_d_cam_pitch->setStateCheck(true);
	else
		m_d_cam_pitch->setStateCheck(false);

	if (GameSettingsMap["Creak Sound"] == "No")
		m_d_creak_sound->setStateCheck(true);
	else
		m_d_creak_sound->setStateCheck(false);

	//Fov
	m_fovexternal->setCaption(GameSettingsMap["FOV External"]);
	m_fovinternal->setCaption(GameSettingsMap["FOV Internal"]);

	
	//Texture Filtering
	Ogre::String texfilter = GameSettingsMap["Texture Filtering"];
	if (texfilter == "Bilinear")
		m_tex_filter->setIndexSelected(1);
	else if (texfilter == "Trilinear")
		m_tex_filter->setIndexSelected(2);
	else if (texfilter == "Anisotropic (best looking)")
		m_tex_filter->setIndexSelected(3);
	else
		m_tex_filter->setIndexSelected(0);

	if (!IsLoaded)
	{
		m_water_type->addItem("Hydrax"); //It's working good enough to be here now. 
	}

	if (BSETTING("DevMode", false) && !IsLoaded)
	{
		//Things that aren't ready to be used yet.
		m_sky_type->addItem("SkyX (best looking, slower)");
		m_shadow_type->addItem("Parallel-split Shadow Maps");
	}

	//Sky effects
	Ogre::String skytype = GameSettingsMap["Sky effects"];
	if (skytype == "Caelum (best looking, slower)")
		m_sky_type->setIndexSelected(1);
	else if (skytype == "SkyX (best looking, slower)" && BSETTING("DevMode", false))
		m_sky_type->setIndexSelected(2);
	else
		m_sky_type->setIndexSelected(0);

	//Shadow technique
	Ogre::String shadowtype = GameSettingsMap["Shadow technique"];
	if (shadowtype == "Texture shadows")
		m_shadow_type->setIndexSelected(1);
	else if (shadowtype == "Stencil shadows (best looking)")
		m_shadow_type->setIndexSelected(2);
	else if (shadowtype == "Parallel-split Shadow Maps" && BSETTING("DevMode", false))
		m_shadow_type->setIndexSelected(3);
	else
		m_shadow_type->setIndexSelected(0);

	//Water effects
	Ogre::String watertype = GameSettingsMap["Water effects"];
	if (watertype == "Reflection")
		m_water_type->setIndexSelected(1);
	else if (watertype == "Reflection + refraction (speed optimized)")
		m_water_type->setIndexSelected(2);
	else if (watertype == "Reflection + refraction (quality optimized)")
		m_water_type->setIndexSelected(3);
	else if (watertype == "Hydrax")
		m_water_type->setIndexSelected(4);
	else
		m_water_type->setIndexSelected(0);
		
	//Vegetation
	Ogre::String vegetationtype = GameSettingsMap["Vegetation"];
	if (vegetationtype == "20%")
		m_vegetation->setIndexSelected(1);
	else if (vegetationtype == "50%")
		m_vegetation->setIndexSelected(2);
	else if (vegetationtype == "Full (best looking, slower)")
		m_vegetation->setIndexSelected(3);
	else
		m_vegetation->setIndexSelected(0);

	//Light source effects
	Ogre::String lightstype = GameSettingsMap["Lights"];
	if (lightstype == "Only current vehicle, main lights")
		m_light_source_effects->setIndexSelected(1);
	else if (lightstype == "All vehicles, main lights")
		m_light_source_effects->setIndexSelected(2);
	else if (lightstype == "All vehicles, all lights")
		m_light_source_effects->setIndexSelected(3);
	else
		m_light_source_effects->setIndexSelected(0);
	
	//Speed until selection
	Ogre::String speedunit = GameSettingsMap["SpeedUnit"];
	if (speedunit == "Metric")
		m_speed_unit->setIndexSelected(1);
	else
		m_speed_unit->setIndexSelected(0);

	//Other configs
	if (GameSettingsMap["DigitalSpeedo"] == "Yes")
		m_digital_speedo->setStateCheck(true);
	else
		m_digital_speedo->setStateCheck(false);

	if (GameSettingsMap["Particles"] == "Yes")
		m_psystem->setStateCheck(true);
	else
		m_psystem->setStateCheck(false);

	if (GameSettingsMap["HeatHaze"] == "Yes")
		m_heathaze->setStateCheck(true);
	else
		m_heathaze->setStateCheck(false);

	if (GameSettingsMap["Mirrors"] == "Yes")
		m_mirrors->setStateCheck(true);
	else
		m_mirrors->setStateCheck(false);

	if (GameSettingsMap["Sunburn"] == "Yes")
		m_sunburn->setStateCheck(true);
	else
		m_sunburn->setStateCheck(false);

	if (GameSettingsMap["HDR"] == "Yes")
		m_hdr->setStateCheck(true);
	else
		m_hdr->setStateCheck(false);

	if (GameSettingsMap["Motion blur"] == "Yes")
		m_mblur->setStateCheck(true);
	else
		m_mblur->setStateCheck(false);

	if (GameSettingsMap["Skidmarks"] == "Yes")
		m_skidmarks->setStateCheck(true);
	else
		m_skidmarks->setStateCheck(false);

	if (GameSettingsMap["Envmap"] == "Yes")
		m_hq_ref->setStateCheck(true);
	else
		m_hq_ref->setStateCheck(false);

	if (GameSettingsMap["Glow"] == "Yes")
		m_glow->setStateCheck(true);
	else
		m_glow->setStateCheck(false);

	if (GameSettingsMap["DOF"] == "Yes")
		m_dof->setStateCheck(true);
	else
		m_dof->setStateCheck(false);

	if (GameSettingsMap["Waves"] == "Yes")
		m_e_waves->setStateCheck(true);
	else
		m_e_waves->setStateCheck(false);

	if (GameSettingsMap["Shadow optimizations"] == "Yes")
		m_sh_pf_opti->setStateCheck(true);
	else
		m_sh_pf_opti->setStateCheck(false);

	if (GameSettingsMap["AsynchronousPhysics"] == "Yes")
		m_enable_async_physics->setStateCheck(true);
	else
		m_enable_async_physics->setStateCheck(false);

	if (GameSettingsMap["DisableCollisions"] == "Yes")
		m_disable_inter_collsion->setStateCheck(true);
	else
		m_disable_inter_collsion->setStateCheck(false);

	if (GameSettingsMap["DisableSelfCollisions"] == "Yes")
		m_disable_intra_collision->setStateCheck(true);
	else
		m_disable_intra_collision->setStateCheck(false);

	if (GameSettingsMap["Multi-threading"] == "No")
		m_disable_multithreading->setStateCheck(true);
	else
		m_disable_multithreading->setStateCheck(false);

	//Volume slider
	long sound_volume = Ogre::StringConverter::parseLong(GameSettingsMap["Sound Volume"], 100);
	m_volume_slider->setScrollRange(101);
	m_volume_slider->setScrollPosition(sound_volume -1);
	if (m_volume_slider->getScrollPosition() >= 100)
		m_volume_indicator->setCaption("100%");
	else
		m_volume_indicator->setCaption(Ogre::StringConverter::toString(sound_volume) + "%");

	//Audio Devices
	valuecounter = 0; //Back to default
	char *devices = (char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
	while (devices && *devices != 0)
	{
		if (!IsLoaded)
		{
			m_audio_dev->addItem(Ogre::String(devices));
		}
		if (Ogre::String(devices) == GameSettingsMap["AudioDevice"])
			m_audio_dev->setIndexSelected(valuecounter);

		devices += strlen(devices) + 1; //next device
		valuecounter++;
	}

	//FPS Limiter slider
	long fps_limit = Ogre::StringConverter::parseLong(GameSettingsMap["FPS-Limiter"], 60);
	m_fps_limiter_slider->setScrollRange(200);
	m_fps_limiter_slider->setScrollPosition(fps_limit -1);


	if (fps_limit >= 199)
		m_fps_limiter_indicator->setCaption("Unlimited");
	else
		m_fps_limiter_indicator->setCaption(Ogre::StringConverter::toString(fps_limit) + " FPS");

	//SightRange slider
	long sight_range = Ogre::StringConverter::parseLong(GameSettingsMap["SightRange"], 5000);
	m_sightrange->setScrollRange(5000);
	m_sightrange->setScrollPosition(sight_range -1);
	if (sight_range >= 4999)
		m_sightrange_indicator->setCaption("Unlimited");
	else
		m_sightrange_indicator->setCaption(Ogre::StringConverter::toString(sight_range) + " m");		

	if (GameSettingsMap["Replay mode"] == "Yes")
		m_enable_replay->setStateCheck(true);
	else
		m_enable_replay->setStateCheck(false);

	if (GameSettingsMap["Screenshot Format"] == "png (bigger, no quality loss)")
		m_hq_screenshots->setStateCheck(true);
	else
		m_hq_screenshots->setStateCheck(false);

	if (GameSettingsMap["ChatAutoHide"] == "Yes")
		m_autohide_chatbox->setStateCheck(true);
	else
		m_autohide_chatbox->setStateCheck(false);
}