Gazebo Rendering

API Reference

6.7.0
gz/rendering/ogre/OgreRenderTarget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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_OGRE_OGRERENDERTARGET_HH_
18 #define GZ_RENDERING_OGRE_OGRERENDERTARGET_HH_
19 
20 #include <gz/math/Color.hh>
21 
29 
30 namespace Ogre
31 {
32  class Camera;
33  class RenderTarget;
34  class Texture;
35 }
36 
37 namespace ignition
38 {
39  namespace rendering
40  {
41  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
42  //
43  class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTarget :
44  public virtual BaseRenderTarget<OgreObject>
45  {
46  protected: OgreRenderTarget();
47 
48  public: virtual ~OgreRenderTarget();
49 
50  public: virtual unsigned int AntiAliasing() const;
51 
52  public: virtual void SetAntiAliasing(unsigned int _aa);
53 
54  public: virtual void Copy(Image &_image) const override;
55 
62  private: bool CopyToBuffer(const PixelBuffer &_dst) const;
63 
64  public: virtual Ogre::Camera *Camera() const;
65 
66  public: virtual void SetCamera(Ogre::Camera *_camera);
67 
68  // Documentation inherited
69  public: virtual math::Color BackgroundColor() const override;
70 
71  public: virtual void SetBackgroundColor(math::Color _color);
72 
73  // Documentation inherited.
74  public: virtual void PreRender() override;
75 
76  // Documentation inherited.
77  public: virtual void PostRender() override;
78 
79  public: virtual void Render();
80 
81  public: virtual void Destroy() override = 0;
82 
86  public: void SetMaterial(MaterialPtr _material);
87 
88  public: virtual Ogre::RenderTarget *RenderTarget() const = 0;
89 
90  public: Ogre::Viewport *AddViewport(Ogre::Camera *_viewport);
91 
92  public: Ogre::Viewport *Viewport(const int _viewportId) const;
93 
94  public: void SetUpdate(const bool _value);
95 
96  public: void SetAutoUpdated(const bool _value);
97 
101  public: virtual void SetVisibilityMask(uint32_t _mask);
102 
103  protected: virtual void UpdateBackgroundColor();
104 
106  protected: virtual void UpdateRenderPassChain();
107 
108  protected: virtual void RebuildImpl() override;
109 
110  protected: virtual void RebuildTarget() = 0;
111 
112  protected: virtual void RebuildViewport();
113 
118  protected: void RebuildMaterial();
119 
120  protected: Ogre::Camera *ogreCamera = nullptr;
121 
122  protected: Ogre::Viewport *ogreViewport = nullptr;
123 
124  protected: Ogre::ColourValue ogreBackgroundColor;
125 
127  protected: MaterialPtr material;
128 
131 
132  protected: bool colorDirty = true;
133 
134  protected: unsigned int antiAliasing = 4;
135 
137  protected: uint32_t visibilityMask = IGN_VISIBILITY_ALL;
138  };
139 
140  class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderTexture :
141  public virtual BaseRenderTexture<OgreRenderTarget>
142  {
143  protected: OgreRenderTexture();
144 
145  public: virtual ~OgreRenderTexture();
146 
147  public: virtual void Destroy() override;
148 
149  // Documentation inherited.
150  public: virtual void PreRender() override;
151 
152  // Documentation inherited.
153  public: virtual void PostRender() override;
154 
155  // Documentation inherited.
156  public: virtual unsigned int GLId();
157 
158  public: virtual void Buffer(float *buffer);
159 
160  public: virtual Ogre::RenderTarget *RenderTarget() const override;
161 
162  protected: virtual void RebuildTarget() override;
163 
164  protected: virtual void DestroyTarget();
165 
166  protected: virtual void BuildTarget();
167 
168  protected: Ogre::Texture *ogreTexture = nullptr;
169 
170  private: friend class OgreScene;
171  };
172 
173  class IGNITION_RENDERING_OGRE_VISIBLE OgreRenderWindow :
174  public virtual BaseRenderWindow<OgreRenderTarget>
175  {
176  protected: OgreRenderWindow();
177 
178  public: virtual ~OgreRenderWindow();
179 
180  public: virtual void Destroy();
181 
182  protected: virtual Ogre::RenderTarget *RenderTarget() const;
183 
184  protected: virtual void RebuildTarget();
185 
186  protected: virtual void BuildTarget();
187 
188  protected: Ogre::RenderTarget *ogreRenderWindow = nullptr;
189 
190  private: friend class OgreScene;
191  };
192  }
193  }
194 }
195 #endif
Definition: gz/rendering/base/BaseRenderTarget.hh:38
Definition: gz/rendering/base/BaseRenderTarget.hh:101
Definition: gz/rendering/base/BaseRenderTarget.hh:114
Encapsulates a raw image buffer and relevant properties.
Definition: gz/rendering/Image.hh:40
Definition: gz/rendering/ogre/OgreRenderTarget.hh:45
Ogre::Viewport * AddViewport(Ogre::Camera *_viewport)
virtual void SetVisibilityMask(uint32_t _mask)
Set visibility mask for the viewport associated with this render target.
virtual unsigned int AntiAliasing() const
void SetAutoUpdated(const bool _value)
virtual void Copy(Image &_image) const override
Write rendered image to given Image. The RenderTarget will convert the underlying image to the specif...
virtual void SetCamera(Ogre::Camera *_camera)
void RebuildMaterial()
Re-initializes render target material to apply a material to everything in the scene....
Ogre::Viewport * Viewport(const int _viewportId) const
virtual Ogre::RenderTarget * RenderTarget() const =0
virtual void UpdateRenderPassChain()
Update render pass chain if changes were made.
virtual void SetBackgroundColor(math::Color _color)
Ogre::ColourValue ogreBackgroundColor
Definition: gz/rendering/ogre/OgreRenderTarget.hh:124
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
virtual void PostRender() override
Post process this object and any of its children after rendering.
void SetMaterial(MaterialPtr _material)
Set a material to render on every object. This method is used for special cases like the render targe...
void SetUpdate(const bool _value)
virtual void SetAntiAliasing(unsigned int _aa)
OgreRenderTargetMaterialPtr materialApplicator
Helper class that applies the material to the render target.
Definition: gz/rendering/ogre/OgreRenderTarget.hh:130
virtual void Destroy() override=0
virtual math::Color BackgroundColor() const override
Get the background color of the render target. This should be the same as the scene background color.
virtual void RebuildImpl() override
virtual Ogre::Camera * Camera() const
MaterialPtr material
a material used by for the render target
Definition: gz/rendering/ogre/OgreRenderTarget.hh:127
Definition: gz/rendering/ogre/OgreRenderTarget.hh:142
virtual Ogre::RenderTarget * RenderTarget() const override
virtual void RebuildTarget() override
virtual void PreRender() override
Prepare this object and any of its children for rendering. This should be called for each object in a...
virtual void Buffer(float *buffer)
virtual void PostRender() override
Post process this object and any of its children after rendering.
Definition: gz/rendering/ogre/OgreRenderTarget.hh:175
virtual Ogre::RenderTarget * RenderTarget() const
Definition: gz/rendering/ogre/OgreScene.hh:41
Non owning, writable view of a caller owned pixel buffer.
Definition: gz/rendering/PixelBuffer.hh:49
#define IGN_VISIBILITY_ALL
Render everything visibility mask.
Definition: gz/rendering/RenderTypes.hh:26
Definition: gz/rendering/ogre/OgreCamera.hh:28