Class Texture
Defined in File Texture.h
Nested Relationships
Nested Types
Class Documentation
-
class Texture
Resource management for OpenGL 2D or Cube textures.
The texture is generated when images are assigned via assignImage2D() or assignCubeImages().
See also
CRenderizableShaderTexturedTriangles
Public Types
Public Functions
-
Texture() = default
-
inline ~Texture()
-
void assignImage2D(const mrpt::img::CImage &rgb, const Options &o, int textureUnit = 0)
This is how an 2D texture image is loaded into this object, and a texture ID is generated underneath. Valid image formats are 8bit per channel RGB or RGBA.
-
void assignImage2D(const mrpt::img::CImage &rgb, const mrpt::img::CImage &alpha, const Options &o, int textureUnit = 0)
-
void assignCubeImages(const std::array<mrpt::img::CImage, 6> &imgs, int textureUnit = 0)
This is how an Cube texture is loaded into this object, and a texture ID is generated underneath. Valid image formats are 8bit per channel RGB or RGBA.
Indices of faces in the array follow the numeric ordering of mrpt::opengl::CUBE_TEXTURE_FACE values.
-
bool initialized() const
Returns true if an image has been already assigned and an OpenGL texture ID was already generated.
-
void bindAsTexture2D()
Binds the texture to GL_TEXTURE_2D
-
void bindAsCubeTexture()
Binds the texture to GL_TEXTURE_CUBE_MAP
-
void unloadTexture()
-
inline texture_unit_t textureUnit() const
Texture unit = the “i” in GL_TEXTUREi
-
inline texture_name_t textureNameID() const
-
struct Options
Options while creating a texture from an image.
Public Functions
-
Options() = default
Public Members
-
bool generateMipMaps = true
-
bool magnifyLinearFilter = true
If set (true), interpolation will happen when getting closer to the texture (magnify). Otherwise (false), it will be not interpolated, so each pixel will be rendered as a square box with constant color (e.g. suitable for gridmaps)
-
bool enableTransparency = false
-
bool isColorData = true
If true (default), the texture is treated as sRGB color and auto-decoded to linear space by the GPU. Set to false for data textures like normal maps.
Textures assigned from the same image (same pixel buffer, alpha image and options) are uploaded once and shared, but only among those with the same non-null shareScope. A scope must only be used with one OpenGL context, since texture names are not valid in other contexts (unless explicitly shared). nullptr (default): the texture is never shared. CompiledScene uses the EGL context it is compiled in, or one scope for all non-EGL contexts.
-
Options() = default
-
Texture() = default