Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre/OgreRenderEngine.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_RENDERING_OGRE_OGRERENDERENGINE_HH_
18 #define GZ_RENDERING_OGRE_OGRERENDERENGINE_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include <gz/common/SingletonT.hh>
26 
32 #include "gz/rendering/ogre/Export.hh"
33 
34 namespace Ogre
35 {
36  class LogManager;
37  class Root;
38 }
39 
40 namespace gz
41 {
42  namespace rendering
43  {
44  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
45  //
46  // forward declaration
47  class OgreRenderEnginePrivate;
48 
50  class GZ_RENDERING_OGRE_VISIBLE OgreRenderEnginePlugin :
51  public RenderEnginePlugin
52  {
54  public: OgreRenderEnginePlugin();
55 
57  public: ~OgreRenderEnginePlugin() = default;
58 
61  public: std::string Name() const;
62 
65  public: RenderEngine *Engine() const;
66  };
67 
68  class GZ_RENDERING_OGRE_VISIBLE OgreRenderEngine :
69  public virtual BaseRenderEngine,
70  public common::SingletonT<OgreRenderEngine>
71  {
74  public: enum OgreRenderPathType
75  {
77  NONE = 0,
79  VERTEX = 1,
81  FORWARD = 2,
83  DEFERRED = 3,
85  RENDER_PATH_COUNT
86  };
87 
89  private: OgreRenderEngine();
90 
91  public: virtual ~OgreRenderEngine();
92 
93  public: virtual void Destroy() override;
94 
95  public: virtual bool IsEnabled() const override;
96 
97  public: virtual std::string Name() const override;
98 
99  public: OgreRenderPathType RenderPathType() const;
100 
101  public: void AddResourcePath(const std::string &_uri) override;
102 
103  // Documentation Inherited
104  public: virtual rendering::GraphicsAPI GraphicsAPI() const override;
105 
106  public: virtual Ogre::Root *OgreRoot() const;
107 
108  public: std::string CreateRenderWindow(const std::string &_handle,
109  const unsigned int _width, const unsigned int _height,
110  const double _ratio, const unsigned int _antiAliasing);
111 
114  public: std::vector<unsigned int> FSAALevels() const;
115 
119  public: static OgreRenderEngine *Instance();
120 
121  protected: virtual ScenePtr CreateSceneImpl(unsigned int _id,
122  const std::string &_name) override;
123 
124  protected: virtual SceneStorePtr Scenes() const override;
125 
131  protected: virtual bool LoadImpl(
132  const std::map<std::string, std::string> &_params) override;
133 
134  protected: virtual bool InitImpl() override;
135 
136  private: void LoadAttempt();
137 
138  private: void CreateLogger();
139 
140  private: void CreateContext();
141 
142  private: void CreateRoot();
143 
144  private: void CreateOverlay();
145 
146  private: void LoadPlugins();
147 
148  private: void CreateRenderSystem();
149 
150  private: void CreateResources();
151 
152  private: void CreateRenderWindow();
153 
154  private: void CheckCapabilities();
155 
156  private: void InitAttempt();
157 
158 #if (OGRE_VERSION >= ((1 << 16) | (9 << 8) | 0))
159  public: Ogre::OverlaySystem *OverlaySystem() const;
163 
164  private: Ogre::OverlaySystem *ogreOverlaySystem = nullptr;
165 
166 #endif
167  private: OgreSceneStorePtr scenes;
168 
169  private: OgreRenderPathType renderPathType;
170 
171  private: Ogre::Root *ogreRoot = nullptr;
172 
173  private: Ogre::LogManager *ogreLogManager = nullptr;
174 
176  private: std::vector<std::string> ogrePaths;
177 
178 #if !defined(__APPLE__) && !defined(_WIN32)
179  private: void *dummyDisplay = nullptr;
180 
181  private: void *dummyContext = nullptr;
182 #endif
183 
184  private: uint64_t dummyWindowId = 0u;
185 
187  private: bool useCurrentGLContext = false;
188 
190 
191  private: friend class common::SingletonT<OgreRenderEngine>;
192  };
193  }
194  }
195 }
196 #endif