test_depth_peeling.cpp
Go to the documentation of this file.
00001 #include <OGRE/Ogre.h>
00002 
00003 #include <ros/package.h>
00004 
00005 int main(int argc, char** argv)
00006 {
00007   Ogre::LogManager* log_manager = new Ogre::LogManager();
00008   log_manager->createLog( "Ogre.log", false, false, false );
00009 
00010   std::string plugin_cfg = "/etc/OGRE/plugins.cfg";
00011   bool has_plugin_cfg = false;
00012 #ifdef HAS_INSTALLED_OGRE
00013   has_plugin_cfg = true;
00014 #else
00015   plugin_cfg = "";
00016 #endif
00017 
00018   Ogre::Root* root = new Ogre::Root( plugin_cfg );
00019   if ( !has_plugin_cfg )
00020   {
00021     root->loadPlugin( "RenderSystem_GL" );
00022     root->loadPlugin( "Plugin_OctreeSceneManager" );
00023     root->loadPlugin( "Plugin_CgProgramManager" );
00024   }
00025 
00026   // Taken from gazebo
00027   Ogre::RenderSystem* render_system = NULL;
00028 #if OGRE_VERSION_MAJOR >=1 && OGRE_VERSION_MINOR >= 7
00029   const Ogre::RenderSystemList& rsList = root->getAvailableRenderers();
00030   Ogre::RenderSystemList::const_iterator renderIt = rsList.begin();
00031   Ogre::RenderSystemList::const_iterator renderEnd = rsList.end();
00032 #else
00033   Ogre::RenderSystemList* rsList = root->getAvailableRenderers();
00034   Ogre::RenderSystemList::iterator renderIt = rsList->begin();
00035   Ogre::RenderSystemList::iterator renderEnd = rsList->end();
00036 #endif
00037   for ( ; renderIt != renderEnd; ++renderIt )
00038   {
00039     render_system = *renderIt;
00040 
00041     if ( render_system->getName() == "OpenGL Rendering Subsystem" )
00042     {
00043       break;
00044     }
00045   }
00046 
00047   if ( render_system == NULL )
00048   {
00049     throw std::runtime_error( "Could not find the opengl rendering subsystem!\n" );
00050   }
00051 
00052   render_system->setConfigOption("FSAA","2");
00053   render_system->setConfigOption("RTT Preferred Mode", "FBO");
00054   render_system->setConfigOption("Full Screen", "False");
00055   render_system->setConfigOption("Video Mode", "800 x 600");
00056 
00057   root->setRenderSystem( render_system );
00058 
00059   //if (root->restoreConfig() || root->showConfigDialog())
00060   {
00061     Ogre::RenderWindow* wnd = root->initialise(true);
00062     wnd->setActive(true);
00063     wnd->setAutoUpdated(true);
00064     wnd->setVisible(true);
00065 
00066     Ogre::ResourceGroupManager::getSingleton().createResourceGroup(ROS_PACKAGE_NAME);
00067 
00068     std::string pkg_path = ros::package::getPath(ROS_PACKAGE_NAME);
00069     Ogre::ResourceGroupManager::getSingleton().addResourceLocation( pkg_path + "/media/textures", "FileSystem", ROS_PACKAGE_NAME );
00070     Ogre::ResourceGroupManager::getSingleton().addResourceLocation( pkg_path + "/media/fonts", "FileSystem", ROS_PACKAGE_NAME );
00071     Ogre::ResourceGroupManager::getSingleton().addResourceLocation( pkg_path + "/media/models", "FileSystem", ROS_PACKAGE_NAME );
00072     Ogre::ResourceGroupManager::getSingleton().addResourceLocation( pkg_path + "/media/materials/programs", "FileSystem", ROS_PACKAGE_NAME );
00073     Ogre::ResourceGroupManager::getSingleton().addResourceLocation( pkg_path + "/media/materials/scripts", "FileSystem", ROS_PACKAGE_NAME );
00074     Ogre::ResourceGroupManager::getSingleton().addResourceLocation( pkg_path + "/media/compositors", "FileSystem", ROS_PACKAGE_NAME );
00075     Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
00076 
00077     Ogre::LogManager::getSingleton().getDefaultLog()->setDebugOutputEnabled(true);
00078     Ogre::LogManager::getSingleton().getDefaultLog()->setLogDetail(Ogre::LL_BOREME);
00079 
00080     Ogre::SceneManager* sm = root->createSceneManager(Ogre::ST_GENERIC);
00081     Ogre::Camera* cam = sm->createCamera("Camera");
00082     Ogre::Viewport* vp = wnd->addViewport(cam);
00083 
00084     cam->setPosition(0, 0, 2);
00085     cam->lookAt(0, 0, 0);
00086     cam->setNearClipDistance(0.01);
00087 
00088     Ogre::SceneNode* sn = sm->getRootSceneNode()->createChildSceneNode();
00089     Ogre::Entity* ent = sm->createEntity("sphere.mesh");//Ogre::SceneManager::PT_SPHERE);
00090     ent->setMaterialName("BaseWhite");
00091     sn->attachObject(ent);
00092     sn->setVisible(true);
00093     sn->setPosition(0, 0, 0);
00094 
00095     root->startRendering();
00096   }
00097 
00098   return 0;
00099 }


rve_render_server
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:15