Gazebo Rendering

API Reference

10.1.0
Ogre2RenderTarget.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_OGRE2RENDERTARGET_HH_
18#define GZ_RENDERING_OGRE2_OGRE2RENDERTARGET_HH_
19
20#include <memory>
21#include <string>
22#include <vector>
23#include <gz/math/Color.hh>
24
30
31#ifdef _MSC_VER
32 #pragma warning(push, 0)
33#endif
34#include <Compositor/OgreCompositorShadowNode.h>
35#ifdef _MSC_VER
36 #pragma warning(pop)
37#endif
38
39namespace Ogre
40{
41 class Camera;
42 class RenderTarget;
43 class Texture;
44}
45
46namespace gz
47{
48 namespace rendering
49 {
50 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
51 //
52 // forward declaration
53 class Ogre2RenderTargetPrivate;
54
56 class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderTarget :
57 public virtual BaseRenderTarget<Ogre2Object>
58 {
60 protected: Ogre2RenderTarget();
61
63 public: virtual ~Ogre2RenderTarget();
64
66 public: virtual unsigned int AntiAliasing() const;
67
70 public: virtual void SetAntiAliasing(unsigned int _aa);
71
74 public: virtual void Copy(Image &_image) const override;
75
82 private: bool CopyToBuffer(const PixelBuffer &_dst) const;
83
86 public: virtual Ogre::Camera *Camera() const;
87
90 public: virtual void SetCamera(Ogre::Camera *_camera);
91
92 // Documentation inherited
93 public: virtual math::Color BackgroundColor() const override;
94
97 public: virtual void SetBackgroundColor(math::Color _color);
98
101 public: virtual void SetBackgroundMaterial(MaterialPtr _material);
102
105 public: virtual MaterialPtr BackgroundMaterial() const;
106
107 // Documentation inherited
108 public: virtual void PreRender() override;
109
110 // Documentation inherited
111 public: virtual void PostRender() override;
112
114 public: virtual void Render();
115
117 public: virtual void Destroy() override = 0;
118
122 public: void SetMaterial(MaterialPtr _material);
123
126
130 protected: uint8_t TargetFSAA() const;
131
136 public: static uint8_t TargetFSAA(uint8_t _fsaa);
137
141 protected: Ogre::TextureGpu *RenderTargetImpl() const;
142
145 public: virtual Ogre::TextureGpu *RenderTarget() const = 0;
146
149 public: virtual bool IsRenderWindow() const;
150
151 // Documentation inherited
152 public: unsigned int GLIdImpl() const;
153
154 // Documentation inherited
155 public: void MetalIdImpl(void *_textureIdPtr) const;
156
159
161 protected: void DestroyTargetImpl();
162
164 protected: void BuildTargetImpl();
165
169 public: virtual uint32_t VisibilityMask() const;
170
174 public: virtual void SetVisibilityMask(uint32_t _mask);
175
177 public: static void UpdateRenderPassChain(
178 Ogre::CompositorWorkspace *_workspace,
179 const std::string &_workspaceDefName,
180 const std::string &_baseNode, const std::string &_finalNode,
181 const std::vector<RenderPassPtr> &_renderPasses,
182 bool _recreateNodes,
183 Ogre::TextureGpu *(*_ogreTextures)[2],
184 bool _isRenderWindow);
185
187 protected: virtual void UpdateBackgroundColor();
188
190 protected: virtual void UpdateBackgroundMaterial();
191
193 protected: virtual void UpdateRenderPassChain();
194
196 protected: virtual void RebuildImpl() override;
197
199 protected: virtual void RebuildTarget() = 0;
200
202 protected: virtual void RebuildCompositor();
203
205 protected: virtual void BuildCompositor();
206
208 protected: virtual void DestroyCompositor();
209
214 protected: void RebuildMaterial();
215
217 protected: Ogre::Camera *ogreCamera = nullptr;
218
221 protected: Ogre::CompositorWorkspace *ogreCompositorWorkspace = nullptr;
222
225
227 protected: Ogre::ColourValue ogreBackgroundColor;
228
231
234
237
239 protected: bool colorDirty = true;
240
243 protected: bool backgroundMaterialDirty = false;
244
246 protected: unsigned int antiAliasing = 4;
247
249 protected: uint32_t visibilityMask = GZ_VISIBILITY_ALL;
250
253 };
254
256 class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderTexture :
257 public virtual BaseRenderTexture<Ogre2RenderTarget>
258 {
260 protected: Ogre2RenderTexture();
261
263 public: virtual ~Ogre2RenderTexture();
264
265 // Documentation inherited
266 public: void AddRenderPass(const RenderPassPtr &_pass) override;
267
268 // Documentation inherited
269 public: void RemoveRenderPass(const RenderPassPtr &_pass) override;
270
271 // Documentation inherited
272 public: void RemoveAllRenderPasses() override;
273
274 // Documentation inherited.
275 public: virtual void Destroy() override;
276
277 // Documentation inherited
278 public: virtual void PreRender() override;
279
280 // Documentation inherited
281 public: virtual void PostRender() override;
282
283 // Documentation inherited
284 public: virtual unsigned int GLId() const override;
285
286 // Documentation inherited
287 public: virtual void MetalId(void *_textureIdPtr) const override;
288
289 // Documentation inherited
290 // TODO(anyone): this function should be removed.
291 // We didn't do it to preserve ABI.
292 public: virtual Ogre::TextureGpu *RenderTarget() const override;
293
294 // Documentation inherited.
295 protected: virtual void RebuildTarget() override;
296
298 protected: virtual void DestroyTarget();
299
301 protected: virtual void BuildTarget();
302
304 private: friend class Ogre2Scene;
305 };
306
308 class GZ_RENDERING_OGRE2_VISIBLE Ogre2RenderWindow :
309 public virtual BaseRenderWindow<Ogre2RenderTarget>
310 {
312 protected: Ogre2RenderWindow();
313
315 public: virtual ~Ogre2RenderWindow();
316
317 // Documentation inherited.
318 public: virtual void Destroy() override;
319
320 // Documentation inherited.
321 public: virtual bool IsRenderWindow() const override;
322
323 // Documentation inherited.
324 public: virtual Ogre::TextureGpu *RenderTarget() const override;
325
326 // Documentation inherited.
327 protected: virtual void RebuildTarget() override;
328
330 protected: virtual void BuildTarget();
331
333 protected: Ogre::TextureGpu *ogreRenderWindow = nullptr;
334
336 private: friend class Ogre2Scene;
337 };
338 }
339 }
340}
341#endif