This is a snapshot of a work-in-progress documentation theme. If you feel lost, miss something, or want to see the original Doxygen docs instead, head over to the archived version of this documentation page.

Magnum::RectangleTexture class

Rectangle texture.

See also AbstractTexture documentation for more information.

Usage

Common usage is to fully configure all texture parameters and then set the data from e.g. Image2D. Example configuration:

Image2D image(PixelFormat::RGBA, PixelType::UnsignedByte, {526, 137}, data);

RectangleTexture texture;
texture.setMagnificationFilter(Sampler::Filter::Linear)
    .setMinificationFilter(Sampler::Filter::Linear)
    .setWrapping(Sampler::Wrapping::ClampToEdge)
    .setMaxAnisotropy(Sampler::maxMaxAnisotropy())
    .setStorage(TextureFormat::RGBA8, {526, 137})
    .setSubImage({}, image);

In shader, the texture is used via sampler2DRect, sampler2DRectShadow, isampler2DRect or usampler2DRect. See AbstractShaderProgram documentation for more information about usage in shaders.

Base classes

class AbstractTexture
Base for textures.

Public static functions

static auto maxSize() -> Vector2i
Max supported rectangle texture size.
static auto compressedBlockSize(TextureFormat format) -> Vector2i
static auto compressedBlockDataSize(TextureFormat format) -> Int
static auto wrap(GLuint id, ObjectFlags flags = {}) -> RectangleTexture
Wrap existing OpenGL rectangle texture object.

Constructors, destructors, conversion operators

RectangleTexture() explicit
Constructor.
RectangleTexture(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.

Public functions

void bindImage(Int imageUnit, ImageAccess access, ImageFormat format)
Bind texture to given image unit.
auto setMinificationFilter(Sampler::Filter filter) -> RectangleTexture&
auto setMagnificationFilter(Sampler::Filter filter) -> RectangleTexture&
auto setWrapping(const Array2D<Sampler::Wrapping>& wrapping) -> RectangleTexture&
auto setBorderColor(const Color4& color) -> RectangleTexture&
auto setBorderColor(const Vector4ui& color) -> RectangleTexture&
auto setBorderColor(const Vector4i& color) -> RectangleTexture&
auto setMaxAnisotropy(Float anisotropy) -> RectangleTexture&
auto setSRGBDecode(bool decode) -> RectangleTexture&
template<char r, char g, char b, char a>
auto setSwizzle() -> RectangleTexture&
auto setCompareMode(Sampler::CompareMode mode) -> RectangleTexture&
auto setCompareFunction(Sampler::CompareFunction function) -> RectangleTexture&
auto setDepthStencilMode(Sampler::DepthStencilMode mode) -> RectangleTexture&
auto setStorage(TextureFormat internalFormat, const Vector2i& size) -> RectangleTexture&
auto imageSize() -> Vector2i
Texture image size.
void image(Image2D& image)
Read texture to image.
auto image(Image2D&& image) -> Image2D
void image(BufferImage2D& image, BufferUsage usage)
Read texture to buffer image.
auto image(BufferImage2D&& image, BufferUsage usage) -> BufferImage2D
void compressedImage(CompressedImage2D& image)
Read compressed texture to image.
auto compressedImage(CompressedImage2D&& image) -> CompressedImage2D
void compressedImage(CompressedBufferImage2D& image, BufferUsage usage)
Read compressed texture to buffer image.
auto compressedImage(CompressedBufferImage2D&& image, BufferUsage usage) -> CompressedBufferImage2D
void subImage(const Range2Di& range, Image2D& image)
auto subImage(const Range2Di& range, Image2D&& image) -> Image2D
void subImage(const Range2Di& range, BufferImage2D& image, BufferUsage usage)
auto subImage(const Range2Di& range, BufferImage2D&& image, BufferUsage usage) -> BufferImage2D
void compressedSubImage(const Range2Di& range, CompressedImage2D& image)
auto compressedSubImage(const Range2Di& range, CompressedImage2D&& image) -> CompressedImage2D
void compressedSubImage(const Range2Di& range, CompressedBufferImage2D& image, BufferUsage usage)
auto compressedSubImage(const Range2Di& range, CompressedBufferImage2D&& image, BufferUsage usage) -> CompressedBufferImage2D
auto setImage(TextureFormat internalFormat, const ImageView2D& image) -> RectangleTexture&
auto setImage(TextureFormat internalFormat, BufferImage2D& image) -> RectangleTexture&
auto setImage(TextureFormat internalFormat, BufferImage2D&& image) -> RectangleTexture&
auto setCompressedImage(const CompressedImageView2D& image) -> RectangleTexture&
auto setCompressedImage(CompressedBufferImage2D& image) -> RectangleTexture&
auto setCompressedImage(CompressedBufferImage2D&& image) -> RectangleTexture&
auto setSubImage(const Vector2i& offset, const ImageView2D& image) -> RectangleTexture&
auto setSubImage(const Vector2i& offset, BufferImage2D& image) -> RectangleTexture&
auto setSubImage(const Vector2i& offset, BufferImage2D&& image) -> RectangleTexture&
auto setCompressedSubImage(const Vector2i& offset, const CompressedImageView2D& image) -> RectangleTexture&
auto setCompressedSubImage(const Vector2i& offset, CompressedBufferImage2D& image) -> RectangleTexture&
auto setCompressedSubImage(const Vector2i& offset, CompressedBufferImage2D&& image) -> RectangleTexture&
void invalidateImage()
Invalidate texture.
void invalidateSubImage(const Vector2i& offset, const Vector2i& size)
Invalidate subtexture.

Function documentation

static Vector2i Magnum::RectangleTexture::maxSize()

Max supported rectangle texture size.

The result is cached, repeated queries don't result in repeated OpenGL calls. If ARB_texture_rectangle (part of OpenGL 3.1) is not available, returns zero vector.

static Vector2i Magnum::RectangleTexture::compressedBlockSize(TextureFormat format)

Compressed block size.

See Texture::compressedBlockSize() for more information.

static Int Magnum::RectangleTexture::compressedBlockDataSize(TextureFormat format)

Compressed block data size.

See Texture::compressedBlockDataSize() for more information.

static RectangleTexture Magnum::RectangleTexture::wrap(GLuint id, ObjectFlags flags = {})

Wrap existing OpenGL rectangle texture object.

Parameters
id OpenGL rectangle texture ID
flags Object creation flags

The id is expected to be of an existing OpenGL texture object with target GL_TEXTURE_RECTANGLE. Unlike texture created using constructor, the OpenGL object is by default not deleted on destruction, use flags for different behavior.

Magnum::RectangleTexture::RectangleTexture() explicit

Constructor.

Creates new OpenGL texture object. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the texture is created on first use.

Magnum::RectangleTexture::RectangleTexture(NoCreateT) explicit noexcept

Construct without creating the underlying OpenGL object.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active.

void Magnum::RectangleTexture::bindImage(Int imageUnit, ImageAccess access, ImageFormat format)

Bind texture to given image unit.

Parameters
imageUnit Image unit
access Image access
format Image format

RectangleTexture& Magnum::RectangleTexture::setMinificationFilter(Sampler::Filter filter)

Returns Reference to self (for method chaining)

Set minification filter. See Texture::setMinificationFilter() for more information. Initial value is Sampler::Filter::Linear.

RectangleTexture& Magnum::RectangleTexture::setMagnificationFilter(Sampler::Filter filter)

Returns Reference to self (for method chaining)

Set magnification filter. See Texture::setMagnificationFilter() for more information.

RectangleTexture& Magnum::RectangleTexture::setWrapping(const Array2D<Sampler::Wrapping>& wrapping)

Returns Reference to self (for method chaining)

Set wrapping. Sets wrapping type for coordinates out of LaTeX Math $ [ 0, size - 1 ] $ range. See Texture::setWrapping() for more information. Initial value is Sampler::Wrapping::ClampToEdge.

RectangleTexture& Magnum::RectangleTexture::setBorderColor(const Color4& color)

Returns Reference to self (for method chaining)

Set border color. See Texture::setBorderColor(const Color4&) for more information.

RectangleTexture& Magnum::RectangleTexture::setBorderColor(const Vector4ui& color)

Returns Reference to self (for method chaining)

Set border color for integer texture. See Texture::setBorderColor(const Vector4ui&) for more information.

RectangleTexture& Magnum::RectangleTexture::setBorderColor(const Vector4i& color)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setMaxAnisotropy(Float anisotropy)

Returns Reference to self (for method chaining)

Set max anisotropy. See Texture::setMaxAnisotropy() for more information.

RectangleTexture& Magnum::RectangleTexture::setSRGBDecode(bool decode)

Returns Reference to self (for method chaining)

Set sRGB decoding. See Texture::setSRGBDecode() for more information.

template<char r, char g, char b, char a>
RectangleTexture& Magnum::RectangleTexture::setSwizzle()

Returns Reference to self (for method chaining)

Set component swizzle. See Texture::setSwizzle() for more information.

RectangleTexture& Magnum::RectangleTexture::setCompareMode(Sampler::CompareMode mode)

Returns Reference to self (for method chaining)

Set depth texture comparison mode. See Texture::setCompareMode() for more information.

RectangleTexture& Magnum::RectangleTexture::setCompareFunction(Sampler::CompareFunction function)

Returns Reference to self (for method chaining)

Set depth texture comparison function. See Texture::setCompareFunction() for more information.

RectangleTexture& Magnum::RectangleTexture::setDepthStencilMode(Sampler::DepthStencilMode mode)

Returns Reference to self (for method chaining)

Set depth/stencil texture mode. See Texture::setDepthStencilMode() for more information.

RectangleTexture& Magnum::RectangleTexture::setStorage(TextureFormat internalFormat, const Vector2i& size)

Returns Reference to self (for method chaining)

Set storage. See Texture::setStorage() for more information.

Vector2i Magnum::RectangleTexture::imageSize()

Texture image size.

See Texture::imageSize() for more information.

void Magnum::RectangleTexture::image(Image2D& image)

Read texture to image.

See Texture::image(Int, Image&) for more information.

Image2D Magnum::RectangleTexture::image(Image2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: Image2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte});

void Magnum::RectangleTexture::image(BufferImage2D& image, BufferUsage usage)

Read texture to buffer image.

See Texture::image(Int, BufferImage&, BufferUsage) for more information.

BufferImage2D Magnum::RectangleTexture::image(BufferImage2D&& image, BufferUsage usage)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: BufferImage2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);

void Magnum::RectangleTexture::compressedImage(CompressedImage2D& image)

Read compressed texture to image.

See Texture::compressedImage(Int, CompressedImage&) for more information.

CompressedImage2D Magnum::RectangleTexture::compressedImage(CompressedImage2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: CompressedImage2D image = texture.compressedimage({});

void Magnum::RectangleTexture::compressedImage(CompressedBufferImage2D& image, BufferUsage usage)

Read compressed texture to buffer image.

See Texture::compressedImage(Int, CompressedBufferImage&, BufferUsage) for more information.

CompressedBufferImage2D Magnum::RectangleTexture::compressedImage(CompressedBufferImage2D&& image, BufferUsage usage)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: CompressedBufferImage2D image = texture.compressedImage({}, BufferUsage::StaticRead);

void Magnum::RectangleTexture::subImage(const Range2Di& range, Image2D& image)

Read range of given texture mip level to image.

See Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&) for more information.

Image2D Magnum::RectangleTexture::subImage(const Range2Di& range, Image2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: Image2D image = texture.subImage(range, {PixelFormat::RGBA, PixelType::UnsignedByte});

void Magnum::RectangleTexture::subImage(const Range2Di& range, BufferImage2D& image, BufferUsage usage)

Read range of given texture mip level to buffer image.

See Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, BufferImage&, BufferUsage) for more information.

BufferImage2D Magnum::RectangleTexture::subImage(const Range2Di& range, BufferImage2D&& image, BufferUsage usage)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: BufferImage2D image = texture.subImage(range, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);

CompressedImage2D Magnum::RectangleTexture::compressedSubImage(const Range2Di& range, CompressedImage2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: CompressedImage2D image = texture.compressedSubImage(range, {});

CompressedBufferImage2D Magnum::RectangleTexture::compressedSubImage(const Range2Di& range, CompressedBufferImage2D&& image, BufferUsage usage)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Convenience alternative to the above, example usage: CompressedBufferImage2D image = texture.compressedSubImage(range, {}, BufferUsage::StaticRead);

RectangleTexture& Magnum::RectangleTexture::setImage(TextureFormat internalFormat, const ImageView2D& image)

Returns Reference to self (for method chaining)

Set image data. See Texture::setImage() for more information.

RectangleTexture& Magnum::RectangleTexture::setImage(TextureFormat internalFormat, BufferImage2D& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setImage(TextureFormat internalFormat, BufferImage2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setCompressedImage(const CompressedImageView2D& image)

Returns Reference to self (for method chaining)

Set compressed image data. See Texture::setCompressedImage() for more information.

RectangleTexture& Magnum::RectangleTexture::setCompressedImage(CompressedBufferImage2D& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setCompressedImage(CompressedBufferImage2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setSubImage(const Vector2i& offset, const ImageView2D& image)

Returns Reference to self (for method chaining)

Set image subdata. See Texture::setSubImage() for more information.

RectangleTexture& Magnum::RectangleTexture::setSubImage(const Vector2i& offset, BufferImage2D& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setSubImage(const Vector2i& offset, BufferImage2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setCompressedSubImage(const Vector2i& offset, const CompressedImageView2D& image)

Returns Reference to self (for method chaining)

Set compressed image subdata. See Texture::setCompressedSubImage() for more information.

RectangleTexture& Magnum::RectangleTexture::setCompressedSubImage(const Vector2i& offset, CompressedBufferImage2D& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

RectangleTexture& Magnum::RectangleTexture::setCompressedSubImage(const Vector2i& offset, CompressedBufferImage2D&& image)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::RectangleTexture::invalidateImage()

Invalidate texture.

See Texture::invalidateImage() for more information.

void Magnum::RectangleTexture::invalidateSubImage(const Vector2i& offset, const Vector2i& size)

Invalidate subtexture.

Parameters
offset Offset into the texture
size Size of invalidated data

See Texture::invalidateSubImage() for more information.