Ocean
rendering/TextureFramebuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_TEXTURE_FRAMEBUFFER_H
9 #define META_OCEAN_RENDERING_TEXTURE_FRAMEBUFFER_H
10 
13 
14 #include "ocean/base/Frame.h"
15 
17 
18 namespace Ocean
19 {
20 
21 namespace Rendering
22 {
23 
24 // Forward declaration
25 class TextureFramebuffer;
26 
27 /**
28  * Definition of a smart object reference holding a texture framebuffer.
29  * @see SmartObjectRef, TextureFramebuffer.
30  * @ingroup rendering
31  */
33 
34 /**
35  * This class is the base class for all textures based on a framebuffer.
36  * @ingroup rendering
37  */
38 class OCEAN_RENDERING_EXPORT TextureFramebuffer : virtual public Texture
39 {
40  public:
41 
42  /**
43  * Resizes the texture framebuffer.
44  * @param width The width of the framebuffer in pixel, with range [1, infinity)
45  * @param height The height of the framebuffer in pixel, with range [1, infinity)
46  */
47  virtual bool resize(const unsigned int width, const unsigned int height) = 0;
48 
49  /**
50  * Returns the texture framebuffer's internal pixel format.
51  * @return The pixel format of the texture framebuffer
52  */
53  virtual FrameType::PixelFormat pixelFormat() const = 0;
54 
55  /**
56  * Returns the texture wrap type in s direction.
57  * The default is WRAP_CLAMP.
58  * @return Wrap type in s direction
59  * @exception NotSupportedException Is thrown if this function is not supported
60  * @see setWrapTypeS(), wrapTypeT().
61  */
62  virtual WrapType wrapTypeS() const;
63 
64  /**
65  * Returns the texture wrap type in t direction.
66  * The default is WRAP_CLAMP.
67  * @return Wrap type in t direction
68  * @exception NotSupportedException Is thrown if this function is not supported
69  * @see setWrapTypeT(), wrapTypeS().
70  */
71  virtual WrapType wrapTypeT() const;
72 
73  /**
74  * Sets the texture framebuffer's internal pixel format.
75  * @param pixelFormat The pixel format of the texture framebuffer
76  * @return True, if succeeded
77  */
78  virtual bool setPixelFormat(const FrameType::PixelFormat pixelFormat) = 0;
79 
80  /**
81  * Sets the texture wrap type in s direction.
82  * @param type Wrap type to set
83  * @return True, if succeeded
84  * @exception NotSupportedException Is thrown if this function is not supported
85  * @see wrapTypeS(), setWrapTypeT().
86  */
87  virtual bool setWrapTypeS(const WrapType type);
88 
89  /**
90  * Sets the texture wrap type in t direction.
91  * @param type Wrap type to set
92  * @return True, if succeeded
93  * @exception NotSupportedException Is thrown if this function is not supported
94  * @see wrapTypeT(), setWrapTypeS().
95  */
96  virtual bool setWrapTypeT(const WrapType type);
97 
98  /**
99  * Copies the image content of the color texture to a given frame.
100  * @param frame The frame to which the color texture will be copied, the frame will be adjusted if the pixel format does match
101  * @param subRegion Optional sub-region within the framebuffer to copy; an invalid bounding box to copy the entire framebuffer
102  * @return True, if succeeded
103  */
104  virtual bool copyColorTextureToFrame(Frame& frame, const CV::PixelBoundingBox& subRegion = CV::PixelBoundingBox());
105 
106  /**
107  * Copies the image content of the depth texture to a given frame.
108  * @param frame The frame to which the depth texture will be copied, the frame will be adjusted if the pixel format does match
109  * @param subRegion Optional sub-region within the framebuffer to copy; an invalid bounding box to copy the entire framebuffer
110  * @return True, if succeeded
111  */
112  virtual bool copyDepthTextureToFrame(Frame& frame, const CV::PixelBoundingBox& subRegion = CV::PixelBoundingBox());
113 
114  /**
115  * Returns the type of this object.
116  * @see Object::type().
117  */
118  inline ObjectType type() const override;
119 
120  protected:
121 
122  /**
123  * Creates a new texture object.
124  */
125  TextureFramebuffer() = default;
126 
127  /**
128  * Destructs a texture object.
129  */
131 };
132 
134 {
136 }
137 
138 }
139 
140 }
141 
142 #endif // META_OCEAN_RENDERING_TEXTURE_FRAMEBUFFER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
ObjectType
Definition of different object type.
Definition: Object.h:63
@ TYPE_TEXTURE_FRAMEBUFFER
TextureFramebuffer type.
Definition: Object.h:163
This class is the base class for all textures based on a framebuffer.
Definition: rendering/TextureFramebuffer.h:39
TextureFramebuffer()=default
Creates a new texture object.
virtual bool setWrapTypeS(const WrapType type)
Sets the texture wrap type in s direction.
virtual FrameType::PixelFormat pixelFormat() const =0
Returns the texture framebuffer's internal pixel format.
virtual WrapType wrapTypeS() const
Returns the texture wrap type in s direction.
virtual bool resize(const unsigned int width, const unsigned int height)=0
Resizes the texture framebuffer.
~TextureFramebuffer() override
Destructs a texture object.
virtual bool copyDepthTextureToFrame(Frame &frame, const CV::PixelBoundingBox &subRegion=CV::PixelBoundingBox())
Copies the image content of the depth texture to a given frame.
ObjectType type() const override
Returns the type of this object.
Definition: rendering/TextureFramebuffer.h:133
virtual bool copyColorTextureToFrame(Frame &frame, const CV::PixelBoundingBox &subRegion=CV::PixelBoundingBox())
Copies the image content of the color texture to a given frame.
virtual bool setPixelFormat(const FrameType::PixelFormat pixelFormat)=0
Sets the texture framebuffer's internal pixel format.
virtual bool setWrapTypeT(const WrapType type)
Sets the texture wrap type in t direction.
virtual WrapType wrapTypeT() const
Returns the texture wrap type in t direction.
This class is the base class for all textures.
Definition: rendering/Texture.h:38
WrapType
Definition of different texture wrapping types.
Definition: rendering/Texture.h:96
SmartObjectRef< TextureFramebuffer > TextureFramebufferRef
Definition of a smart object reference holding a texture framebuffer.
Definition: rendering/TextureFramebuffer.h:25
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15