Ocean
GLESTexture.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_TEXTURE_H
9 #define META_OCEAN_RENDERING_GLES_TEXTURE_H
10 
14 
16 
18 
19 #include "ocean/base/Frame.h"
20 
21 namespace Ocean
22 {
23 
24 namespace Rendering
25 {
26 
27 namespace GLESceneGraph
28 {
29 
30 /**
31  * This class is the base class for all GLESceneGraph texture objects.
32  * @ingroup renderinggles
33  */
34 class OCEAN_RENDERING_GLES_EXPORT GLESTexture :
35  virtual public GLESObject,
36  virtual public Texture
37 {
38  public:
39 
40  /**
41  * Returns the texture transformation matrix.
42  * @see Texture::transformation().
43  */
45 
46  /**
47  * Returns the environment mode for this texture.
48  * @see Texture::environmentMode().
49  */
50  EnvironmentMode environmentMode() const override;
51 
52  /**
53  * Returns the minification filter mode for this texture.
54  * @see Texture::minificationFilterMode().
55  */
57 
58  /**
59  * Returns the magnification filter mode for this texture.
60  * @see Texture::magnificationFilterMode().
61  */
63 
64  /**
65  * Returns whether mipmaps are used.
66  * @see Texture::usingMipmaps().
67  */
68  bool usingMipmaps() const override;
69 
70  /**
71  * Sets the texture transformation matrix.
72  * @see Texture::setTransformation().
73  */
74  void setTransformation(const HomogenousMatrix4& transformation) override;
75 
76  /**
77  * Sets the environment mode for this texture.
78  * @see Texture::setEnvironmentMode().
79  */
80  void setEnvironmentMode(const EnvironmentMode mode) override;
81 
82  /**
83  * Sets the minification filter mode for this texture.
84  * @see Texture::setMinificationFilterMode().
85  */
86  void setMinificationFilterMode(const MinFilterMode mode) override;
87 
88  /**
89  * Sets the magnification filter mode for this texture.
90  * @see Texture::setMagnificationFilterMode().
91  */
92  void setMagnificationFilterMode(const MagFilterMode mode) override;
93 
94  /**
95  * Specifies whether mipmaps will be used.
96  * @see Texture::setUseMipmaps().
97  */
98  void setUseMipmaps(const bool flag) override;
99 
100  /**
101  * Binds this texture.
102  * @param shaderProgram Shader programe to bind the texture with
103  * @param id Id of the first free texture
104  * @return Number of bound textures
105  */
106  virtual unsigned int bindTexture(GLESShaderProgram& shaderProgram, const unsigned int id) = 0;
107 
108  /**
109  * Translates a minification filter mode to the corresponding OpenGL filter mode.
110  * @param minificationFilterMode The minification mode to translate
111  * @return The corresponding OpenGL filter mode
112  */
113  static GLenum translateMinificationFilterMode(const MinFilterMode minificationFilterMode);
114 
115  /**
116  * Translates a maginification filter mode to the corresponding OpenGL filter mode.
117  * @param magnificationFilterMode The minification mode to translate
118  * @return The corresponding OpenGL filter mode
119  */
120  static GLenum translateMagnificationFilterMode(const MagFilterMode magnificationFilterMode);
121 
122  /**
123  * Translates a wrap type to the corresponding OpenGL wrap type.
124  * @param wrapType The wrap type to translate
125  * @return The corresponding OpenGL wrap type
126  */
127  static GLenum translateWrapType(const WrapType wrapType);
128 
129  protected:
130 
131  /**
132  * Creates a new GLESceneGraph texture object.
133  */
135 
136  /**
137  * Destructs a GLESceneGraph texture object.
138  */
139  ~GLESTexture() override;
140 
141  /**
142  * Creates or updates the mipmap for this texture.
143  */
144  virtual void createMipmap() = 0;
145 
146  protected:
147 
148  /// Homogenous texture transformation matrix.
150 
151  /// Texture environment mode.
153 
154  /// Texture minification filter mode.
156 
157  /// Texture magnification filter mode.
159 
160  /// True, to create a mipmap for the texture.
162 };
163 
164 }
165 
166 }
167 
168 }
169 
170 #endif // META_OCEAN_RENDERING_GLES_TEXTURE_H
This class is the base class for all GLESceneGraph objects.
Definition: GLESObject.h:57
This class implements a container for an OpenGL ES shader program.
Definition: GLESShaderProgram.h:53
This class is the base class for all GLESceneGraph texture objects.
Definition: GLESTexture.h:37
static GLenum translateWrapType(const WrapType wrapType)
Translates a wrap type to the corresponding OpenGL wrap type.
void setMinificationFilterMode(const MinFilterMode mode) override
Sets the minification filter mode for this texture.
MinFilterMode minificationFilterMode_
Texture minification filter mode.
Definition: GLESTexture.h:155
HomogenousMatrix4 transformation_
Homogenous texture transformation matrix.
Definition: GLESTexture.h:149
bool usingMipmaps() const override
Returns whether mipmaps are used.
EnvironmentMode environmentMode_
Texture environment mode.
Definition: GLESTexture.h:152
static GLenum translateMagnificationFilterMode(const MagFilterMode magnificationFilterMode)
Translates a maginification filter mode to the corresponding OpenGL filter mode.
MagFilterMode magnificationFilterMode() const override
Returns the magnification filter mode for this texture.
bool useMipmap_
True, to create a mipmap for the texture.
Definition: GLESTexture.h:161
GLESTexture()
Creates a new GLESceneGraph texture object.
void setUseMipmaps(const bool flag) override
Specifies whether mipmaps will be used.
static GLenum translateMinificationFilterMode(const MinFilterMode minificationFilterMode)
Translates a minification filter mode to the corresponding OpenGL filter mode.
void setTransformation(const HomogenousMatrix4 &transformation) override
Sets the texture transformation matrix.
MagFilterMode magnificationFilterMode_
Texture magnification filter mode.
Definition: GLESTexture.h:158
void setEnvironmentMode(const EnvironmentMode mode) override
Sets the environment mode for this texture.
~GLESTexture() override
Destructs a GLESceneGraph texture object.
virtual void createMipmap()=0
Creates or updates the mipmap for this texture.
MinFilterMode minificationFilterMode() const override
Returns the minification filter mode for this texture.
EnvironmentMode environmentMode() const override
Returns the environment mode for this texture.
virtual unsigned int bindTexture(GLESShaderProgram &shaderProgram, const unsigned int id)=0
Binds this texture.
void setMagnificationFilterMode(const MagFilterMode mode) override
Sets the magnification filter mode for this texture.
HomogenousMatrix4 transformation() const override
Returns the texture transformation matrix.
This class is the base class for all textures.
Definition: rendering/Texture.h:38
MagFilterMode
Definition of possible magnification filter modes.
Definition: rendering/Texture.h:83
WrapType
Definition of different texture wrapping types.
Definition: rendering/Texture.h:96
EnvironmentMode
Definition of possible texture environment modes.
Definition: rendering/Texture.h:45
MinFilterMode
Definition of possible minification filter modes.
Definition: rendering/Texture.h:61
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15