Gazebo Rendering

API Reference

7.4.2
gz/rendering/ogre2/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  {
64  public: Ogre2RenderEnginePlugin();
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  public common::SingletonT<Ogre2RenderEngine>
84  {
86  private: Ogre2RenderEngine();
87 
89  public: virtual ~Ogre2RenderEngine();
90 
91  // Documentation Inherited.
92  public: virtual void Destroy() override;
93 
94  // Documentation Inherited.
95  public: virtual bool IsEnabled() const override;
96 
97  // Documentation Inherited.
98  public: virtual std::string Name() const override;
99 
102  public: void AddResourcePath(const std::string &_uri) override;
103 
105  public: Ogre::Window * OgreWindow() const;
106 
109  public: virtual Ogre::Root *OgreRoot() const;
110 
119  public: std::string CreateRenderWindow(const std::string &_handle,
120  const unsigned int _width, const unsigned int _height,
121  const double _ratio, const unsigned int _antiAliasing);
122 
123  // Documentation Inherited
124  public: virtual rendering::GraphicsAPI GraphicsAPI() const override;
125 
129  protected: virtual ScenePtr CreateSceneImpl(unsigned int _id,
130  const std::string &_name) override;
131 
135  protected: virtual SceneStorePtr Scenes() const override;
136 
137  // Documentation Inherited.
138  protected: virtual bool LoadImpl(
139  const std::map<std::string, std::string> &_params) override;
140 
143  protected: virtual bool InitImpl() override;
144 
146  private: void LoadAttempt();
147 
149  private: void CreateLogger();
150 
152  private: void CreateContext();
153 
155  private: void RegisterHlms();
156 
158  private: void CreateRoot();
159 
161  private: void CreateOverlay();
162 
164  private: void LoadPlugins();
165 
167  private: void CreateRenderSystem();
168 
170  private: void CreateRenderWindow();
171 
173  private: void CreateResources();
174 
176  private: void InitAttempt();
177 
180  public: std::vector<unsigned int> FSAALevels() const;
181 
183  public: Ogre2GzHlmsSphericalClipMinDistance GZ_DEPRECATED(7) &
184  HlmsCustomizations();
185 
188  public: Ogre2GzHlmsSphericalClipMinDistance &SphericalClipMinDistance();
189 
193  public: Ogre::v1::OverlaySystem *OverlaySystem() const;
194 
199  public: void SetGzOgreRenderingMode(GzOgreRenderingMode renderingMode);
200  // TODO(CH3): Deprecated. Remove on tock.
201  public:
202  inline void GZ_DEPRECATED(7) SetIgnOgreRenderingMode(
203  GzOgreRenderingMode renderingMode)
204  {
205  return SetGzOgreRenderingMode(renderingMode);
206  }
207 
214  public: Ogre::HlmsPbsTerraShadows *HlmsPbsTerraShadows() const;
215 
224  public: Ogre::CompositorWorkspaceListener
225  *TerraWorkspaceListener() const;
226 
230  public: static Ogre2RenderEngine *Instance();
231 
233  private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr;
234 
236  private: Ogre2SceneStorePtr scenes;
237 
239  private: Ogre::Root *ogreRoot = nullptr;
240 
242  private: Ogre::LogManager *ogreLogManager = nullptr;
243 
245  private: std::vector<std::string> ogrePaths;
246 
248  private: void *dummyDisplay = nullptr;
249 
251  private: void *dummyContext = nullptr;
252 
254  private: uint64_t dummyWindowId = 0u;
255 
257  private: Ogre::Window *window = nullptr;
258 
260  private: bool useCurrentGLContext = false;
261 
264 
266  private: friend class common::SingletonT<Ogre2RenderEngine>;
267  };
268  }
269  }
270 }
271 #endif