Gazebo Rendering

API Reference

9.0.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
33#include "gz/rendering/ogre2/Export.hh"
34
35namespace 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
49namespace 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 :
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
188 public: Ogre2GzHlmsSphericalClipMinDistance &SphericalClipMinDistance();
189
193 public: Ogre::v1::OverlaySystem *OverlaySystem() const;
194
199 public: void SetGzOgreRenderingMode(GzOgreRenderingMode renderingMode);
200
207 public: Ogre::HlmsPbsTerraShadows *HlmsPbsTerraShadows() const;
208
217 public: Ogre::CompositorWorkspaceListener
219
222 public: static Ogre2RenderEngine *Instance();
223
225 private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr;
226
228 private: Ogre2SceneStorePtr scenes;
229
231 private: Ogre::Root *ogreRoot = nullptr;
232
234 private: Ogre::LogManager *ogreLogManager = nullptr;
235
237 private: std::vector<std::string> ogrePaths;
238
240 private: void *dummyDisplay = nullptr;
241
243 private: void *dummyContext = nullptr;
244
246 private: uint64_t dummyWindowId = 0u;
247
249 private: Ogre::Window *window = nullptr;
250
252 private: bool useCurrentGLContext = false;
253
256
258 private: friend class common::SingletonT<Ogre2RenderEngine>;
259 };
260 }
261 }
262}
263#endif