class mrpt::opengl::Texture

Overview

Resource management for OpenGL 2D or Cube textures.

The texture is generated when images are assigned via assignImage2D() or assignCubeImages().

See also:

CRenderizableShaderTexturedTriangles

#include <mrpt/opengl/Texture.h>

class Texture
{
public:
    // enums

    enum Wrapping;

    // structs

    struct Options;

    // construction

    Texture();

    // methods

    void assignImage2D(const mrpt::img::CImage& rgb, const Options& o, int textureUnit = 0);

    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);
    bool initialized() const;
    void bindAsTexture2D();
    void bindAsCubeTexture();
    void unloadTexture();
    texture_unit_t textureUnit() const;
    texture_name_t textureNameID() const;
};

Methods

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 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.

texture_unit_t textureUnit() const

Texture unit = the “i” in GL_TEXTUREi.