Gazebo Rendering

API Reference

8.2.0
Ogre2RenderEngine.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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_OGRE2_OGRE2RENDERENGINE_HH_
18 #define GZ_RENDERING_OGRE2_OGRE2RENDERENGINE_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include <gz/common/SingletonT.hh>
26 
33 #include "gz/rendering/ogre2/Export.hh"
34 
35 namespace Ogre
36 {
37  class LogManager;
38  class Root;
39  class Window;
40  namespace v1
41  {
42  class OverlaySystem;
43  }
44 
45  class HlmsPbsTerraShadows;
46  class CompositorWorkspaceListener;
47 }
48 
49 namespace gz
50 {
51  namespace rendering
52  {
53  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
54  //
55  // forward declaration
56  class Ogre2RenderEnginePrivate;
57  class Ogre2GzHlmsSphericalClipMinDistance;
58 
60  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderEnginePlugin :
61  public RenderEnginePlugin
62  {
65 
67  public: ~Ogre2RenderEnginePlugin() = default;
68 
71  public: std::string Name() const;
72 
75  public: RenderEngine *Engine() const;
76  };
77 
81  class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderEngine :
82  public virtual BaseRenderEngine
83  {
85  private: Ogre2RenderEngine();
86 
88  public: virtual ~Ogre2RenderEngine();
89 
90  // Documentation Inherited.
91  public: virtual void Destroy() override;
92 
93  // Documentation Inherited.
94  public: virtual bool IsEnabled() const override;
95 
96  // Documentation Inherited.
97  public: virtual std::string Name() const override;
98 
101  public: void AddResourcePath(const std::string &_uri) override;
102 
104  public: Ogre::Window * OgreWindow() const;
105 
108  public: virtual Ogre::Root *OgreRoot() const;
109 
119  const unsigned int _width, const unsigned int _height,
120  const double _ratio, const unsigned int _antiAliasing);
121 
122  // Documentation Inherited
123  public: virtual rendering::GraphicsAPI GraphicsAPI() const override;
124 
125  // Documentation Inherited
127  const std::string &_winHandle, const uint32_t _width,
128  const uint32_t _height, const double _ratio) override;
129 
133  protected: virtual ScenePtr CreateSceneImpl(unsigned int _id,
134  const std::string &_name) override;
135 
139  protected: virtual SceneStorePtr Scenes() const override;
140 
141  // Documentation Inherited.
142  protected: virtual bool LoadImpl(
143  const std::map<std::string, std::string> &_params) override;
144 
147  protected: virtual bool InitImpl() override;
148 
150  private: void LoadAttempt();
151 
153  private: void CreateLogger();
154 
156  private: void CreateContext();
157 
159  private: void RegisterHlms();
160 
162  private: void CreateRoot();
163 
165  private: void CreateOverlay();
166 
168  private: void LoadPlugins();
169 
171  private: void CreateRenderSystem();
172 
174  private: void CreateRenderWindow();
175 
177  private: void CreateResources();
178 
180  private: void InitAttempt();
181 
185 
187  public: Ogre2GzHlmsSphericalClipMinDistance GZ_DEPRECATED(7) &
189 
192  public: Ogre2GzHlmsSphericalClipMinDistance &SphericalClipMinDistance();
193 
197  public: Ogre::v1::OverlaySystem *OverlaySystem() const;
198 
203  public: void SetGzOgreRenderingMode(GzOgreRenderingMode renderingMode);
204  // TODO(CH3): Deprecated. Remove on tock.
205  public:
206  inline void GZ_DEPRECATED(7) SetIgnOgreRenderingMode(
207  GzOgreRenderingMode renderingMode)
208  {
209  return SetGzOgreRenderingMode(renderingMode);
210  }
211 
218  public: Ogre::HlmsPbsTerraShadows *HlmsPbsTerraShadows() const;
219 
228  public: Ogre::CompositorWorkspaceListener
230 
233  public: static Ogre2RenderEngine *Instance();
234 
236  private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr;
237 
239  private: Ogre2SceneStorePtr scenes;
240 
242  private: Ogre::Root *ogreRoot = nullptr;
243 
245  private: Ogre::LogManager *ogreLogManager = nullptr;
246 
248  private: std::vector<std::string> ogrePaths;
249 
251  private: void *dummyDisplay = nullptr;
252 
254  private: void *dummyContext = nullptr;
255 
257  private: uint64_t dummyWindowId = 0u;
258 
260  private: Ogre::Window *window = nullptr;
261 
263  private: bool useCurrentGLContext = false;
264 
267 
269  private: friend class common::SingletonT<Ogre2RenderEngine>;
270  };
271  }
272  }
273 }
274 #endif