Ocean
Loading...
Searching...
No Matches
GLESFrameTexture2D.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_GLES_FRAME_TEXTURE_2D_H
9#define META_OCEAN_RENDERING_GLES_FRAME_TEXTURE_2D_H
10
13
15
16namespace Ocean
17{
18
19namespace Rendering
20{
21
22namespace GLESceneGraph
23{
24
25/**
26 * This class wraps a GLESceneGraph frame texture object.
27 * @ingroup renderinggles
28 */
29class OCEAN_RENDERING_GLES_EXPORT GLESFrameTexture2D final :
30 virtual public GLESTexture2D,
31 virtual public FrameTexture2D
32{
33 friend class GLESFactory;
34
35 public:
36
37 /**
38 * Sets or updates the texture with a given frame.
39 * @see FrameTexture2D::setTexture().
40 */
41 bool setTexture(Frame&& frame) override;
42
43 /**
44 * Sets or updates the texture with a given buffer.
45 * @see FrameTexture2D::setTexture().
46 */
47 bool setTexture(CompressedFrame&& compressedFrame) override;
48
49 /**
50 * Returns the frame type of this 2D texture.
51 * @see Texture2D::frameType()
52 */
53 FrameType frameType() const override;
54
55 /**
56 * Returns whether this texture contains at least one transparent pixel.
57 * @see Texture2D::hasTransparentPixel();
58 */
59 bool hasTransparentPixel() const override;
60
61 /**
62 * Returns whether the texture internally holds valid data.
63 * @see Texture::isValid().
64 */
65 bool isValid() const override;
66
67 protected:
68
69 /**
70 * Creates a new GLESceneGraph texture 2D object.
71 */
73
74 /**
75 * Destructs a GLESceneGraph texture 2D object.
76 */
78
79 /**
80 * Update function called by the framebuffer.
81 * @see DynamicObject::onDynamicUpdate().
82 */
83 void onDynamicUpdate(const ViewRef& view, const Timestamp timestamp) override;
84
85 /**
86 * Updates the texture based on a given compressed frame.
87 * @param compressedFrame The compressed frame to be used to update the texture, must be valid
88 * @return True, if succeeded
89 */
90 bool updateTexture(const CompressedFrame& compressedFrame);
91
92 /**
93 * Determines the OpenGL format for a given compressed texture format.
94 * @param compressedFormat The texture format for which the OpenGL format will be determined, must be valid
95 * @param internalFormat The resulting OpenGL texture format
96 * @return True, if succeeded
97 */
98 static bool determineCompressedFormat(const CompressedFormat compressedFormat, GLenum& internalFormat);
99
100 /**
101 * Returns the image size for a compressed texture.
102 * @param compressedFormat The texture format of the compressed texture, must be valid
103 * @param width The width of the texture in pixel, with range [1, infinity)
104 * @param height The height of the texture in pixel, with range [1, infinity)
105 * @param size The resulting size of the compressed texture, in bytes
106 * @return True, if succeeded
107 */
108 static bool compressedImageSize(const CompressedFormat compressedFormat, const unsigned int width, const unsigned int height, unsigned int& size);
109
110 protected:
111
112 /// The texture's frame, if any.
114
115 /// The texture's compressed frame, if any.
117
118 /// True, if the texture needs to be updated.
119 bool updateNeeded_ = false;
120};
121
122}
123
124}
125
126}
127
128#endif // META_OCEAN_RENDERING_GLES_FRAME_TEXTURE_2D_H
This class implements Ocean's image class.
Definition Frame.h:1879
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
This class implements a container for a compressed texture.
Definition FrameTexture2D.h:71
This class is the base class for all 2D textures receiving their image content from a frame or a buff...
Definition FrameTexture2D.h:38
CompressedFormat
Definition of individual compressed texture formats.
Definition FrameTexture2D.h:45
This class implements a class factory for all GLESceneGraph objects.
Definition GLESFactory.h:30
This class wraps a GLESceneGraph frame texture object.
Definition GLESFrameTexture2D.h:32
void onDynamicUpdate(const ViewRef &view, const Timestamp timestamp) override
Update function called by the framebuffer.
Frame frame_
The texture's frame, if any.
Definition GLESFrameTexture2D.h:113
bool updateTexture(const CompressedFrame &compressedFrame)
Updates the texture based on a given compressed frame.
FrameType frameType() const override
Returns the frame type of this 2D texture.
bool setTexture(CompressedFrame &&compressedFrame) override
Sets or updates the texture with a given buffer.
bool isValid() const override
Returns whether the texture internally holds valid data.
~GLESFrameTexture2D() override
Destructs a GLESceneGraph texture 2D object.
static bool compressedImageSize(const CompressedFormat compressedFormat, const unsigned int width, const unsigned int height, unsigned int &size)
Returns the image size for a compressed texture.
bool hasTransparentPixel() const override
Returns whether this texture contains at least one transparent pixel.
bool setTexture(Frame &&frame) override
Sets or updates the texture with a given frame.
static bool determineCompressedFormat(const CompressedFormat compressedFormat, GLenum &internalFormat)
Determines the OpenGL format for a given compressed texture format.
CompressedFrame compressedFrame_
The texture's compressed frame, if any.
Definition GLESFrameTexture2D.h:116
GLESFrameTexture2D()
Creates a new GLESceneGraph texture 2D object.
This class wraps a GLESceneGraph texture object.
Definition GLESTexture2D.h:34
This class implements a timestamp.
Definition Timestamp.h:63
The namespace covering the entire Ocean framework.
Definition Accessor.h:15