Gazebo Rendering

API Reference

9.4.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
26
27#include "gz/rendering/config.hh"
34#include "gz/rendering/ogre2/Export.hh"
35
36namespace Ogre
37{
38 class LogManager;
39 class Root;
40 class Window;
41#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
42 namespace v1
43 {
44 class OverlaySystem;
45 }
46#endif
47
48 class HlmsPbsTerraShadows;
49 class CompositorWorkspaceListener;
50}
51
52namespace gz
53{
54 namespace rendering
55 {
56 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
57 //
58 // forward declaration
59 class Ogre2RenderEnginePrivate;
60 class Ogre2GzHlmsSphericalClipMinDistance;
61
63 class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderEnginePlugin :
65 {
68
70 public: ~Ogre2RenderEnginePlugin() = default;
71
74 public: std::string Name() const;
75
78 public: RenderEngine *Engine() const;
79 };
80
84 class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderEngine :
85 public virtual BaseRenderEngine
86 {
88 private: Ogre2RenderEngine();
89
91 public: virtual ~Ogre2RenderEngine();
92
93 // Documentation Inherited.
94 public: virtual void Destroy() override;
95
96 // Documentation Inherited.
97 public: virtual bool IsEnabled() const override;
98
99 // Documentation Inherited.
100 public: virtual std::string Name() const override;
101
104 public: void AddResourcePath(const std::string &_uri) override;
105
107 public: Ogre::Window * OgreWindow() const;
108
111 public: virtual Ogre::Root *OgreRoot() const;
112
122 const unsigned int _width, const unsigned int _height,
123 const double _ratio, const unsigned int _antiAliasing);
124
125 // Documentation Inherited
126 public: virtual rendering::GraphicsAPI GraphicsAPI() const override;
127
128 // Documentation Inherited
130 const std::string &_winHandle, const uint32_t _width,
131 const uint32_t _height, const double _ratio) override;
132
136 protected: virtual ScenePtr CreateSceneImpl(unsigned int _id,
137 const std::string &_name) override;
138
142 protected: virtual SceneStorePtr Scenes() const override;
143
144 // Documentation Inherited.
145 protected: virtual bool LoadImpl(
146 const std::map<std::string, std::string> &_params) override;
147
150 protected: virtual bool InitImpl() override;
151
153 private: void LoadAttempt();
154
156 private: void CreateLogger();
157
159 private: void CreateContext();
160
162 private: void RegisterHlms();
163
165 private: void CreateRoot();
166
167#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
169 private: void CreateOverlay();
170#endif
171
173 private: void LoadPlugins();
174
176 private: void CreateRenderSystem();
177
179 private: void CreateRenderWindow();
180
182 private: void CreateResources();
183
185 private: void InitAttempt();
186
190
193 public: Ogre2GzHlmsSphericalClipMinDistance &SphericalClipMinDistance();
194
195#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
199 public: Ogre::v1::OverlaySystem *OverlaySystem() const;
200#endif
201
206 public: void SetGzOgreRenderingMode(GzOgreRenderingMode renderingMode);
207
214 public: Ogre::HlmsPbsTerraShadows *HlmsPbsTerraShadows() const;
215
224 public: Ogre::CompositorWorkspaceListener
226
229 public: static Ogre2RenderEngine *Instance();
230
231#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY
233 private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr;
234#endif
235
237 private: Ogre2SceneStorePtr scenes;
238
240 private: Ogre::Root *ogreRoot = nullptr;
241
243 private: Ogre::LogManager *ogreLogManager = nullptr;
244
246 private: std::vector<std::string> ogrePaths;
247
249 private: void *dummyDisplay = nullptr;
250
252 private: void *dummyContext = nullptr;
253
255 private: uint64_t dummyWindowId = 0u;
256
258 private: Ogre::Window *window = nullptr;
259
261 private: bool useCurrentGLContext = false;
262
265
267 private: friend class common::SingletonT<Ogre2RenderEngine>;
268 };
269 }
270 }
271}
272#endif