RenderEngine.hh
00001 /*
00002  * Copyright 2011 Nate Koenig & Andrew Howard
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  *
00016 */
00017 /* Desc: Middleman between OGRE and Gazebo
00018  * Author: Nate Koenig
00019  * Date: 13 Feb 2006
00020  */
00021 
00022 #ifndef RENDERENGINE_HH
00023 #define RENDERENGINE_HH
00024 
00025 #include <vector>
00026 
00027 #include "msgs/msgs.h"
00028 #include "common/SingletonT.hh"
00029 #include "common/Event.hh"
00030 #include "transport/TransportTypes.hh"
00031 #include "rendering/RenderTypes.hh"
00032 
00033 namespace Ogre
00034 {
00035   class Root;
00036   class Node;
00037   class LogManager;
00038 }
00039 
00040 
00041 namespace gazebo
00042 {
00043     namespace rendering
00044   {
00047     
00049     class RenderEngine : public SingletonT<RenderEngine>
00050     {
00052       private: RenderEngine();
00053     
00055       private: virtual ~RenderEngine();
00056     
00058       public: void Load();
00059   
00061       public: void Init();
00062   
00064       public: void Fini();
00065     
00067       public: void Save(std::string &prefix, std::ostream &stream);
00068     
00070       public: double GetUpdateRate();
00071   
00073       public: ScenePtr CreateScene(const std::string &name, 
00074                                    bool _enableVisualizations);
00075   
00077       public: void RemoveScene(const std::string &name);
00078 
00080       public: ScenePtr GetScene(const std::string &_name);
00081 
00083       public: ScenePtr GetScene(unsigned int index);
00084   
00086       public: unsigned int GetSceneCount() const;
00087   
00089       public: bool HasGLSL();
00090   
00091       public: void AddResourcePath(const std::string &_path);
00092 
00093       private: void CreateContext();
00094 
00095       private: void LoadPlugins();
00096 
00097       private: void SetupResources();
00098       private: void SetupRenderSystem();
00099   
00100       private: void PreRender();
00101       private: void Render();
00102       private: void PostRender();
00103 
00105       public: Ogre::Root *root;
00106     
00108       private: std::vector< ScenePtr > scenes;
00109     
00110       private: Ogre::LogManager *logManager;
00111    
00113       protected: unsigned long dummyWindowId;
00114   
00116       protected: void *dummyDisplay;
00117       
00119       protected: void* dummyContext;
00120   
00122       private: bool headless;
00123 
00124       private: bool initialized;
00125    
00126       private: std::vector<event::ConnectionPtr> connections;
00127       private: friend class SingletonT<RenderEngine>;
00128 
00129       private: transport::NodePtr node;    
00130 
00131       private: bool removeScene;
00132       private: std::string removeSceneName;
00133     };
00135   }
00136 }
00137 #endif