Magnum::GL::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:

ImageView2D image{PixelFormat::RGBA8Unorm, {526, 137}, data};

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

In a 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
Compressed block size.
static auto compressedBlockDataSize(TextureFormat format) -> Int
Compressed block data size.
static auto view(RectangleTexture& original, TextureFormat internalFormat) -> RectangleTexture new in Git master
Create a view on another rectangle texture.
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.
RectangleTexture(const RectangleTexture&) deleted
Copying is not allowed.
RectangleTexture(RectangleTexture&&) defaulted noexcept
Move constructor.

Public functions

auto operator=(const RectangleTexture&) -> RectangleTexture& deleted
Copying is not allowed.
auto operator=(RectangleTexture&&) -> RectangleTexture& defaulted noexcept
Move assignment.
void bindImage(Int imageUnit, ImageAccess access, ImageFormat format)
Bind texture to given image unit.
auto setMinificationFilter(SamplerFilter filter) -> RectangleTexture&
Set minification filter.
auto setMinificationFilter(Magnum::SamplerFilter filter) -> RectangleTexture&
auto setMagnificationFilter(SamplerFilter filter) -> RectangleTexture&
Set magnification filter.
auto setMagnificationFilter(Magnum::SamplerFilter filter) -> RectangleTexture&
auto setWrapping(const Math::Vector2<SamplerWrapping>& wrapping) -> RectangleTexture&
Set wrapping.
auto setWrapping(const Math::Vector2<Magnum::SamplerWrapping>& wrapping) -> RectangleTexture&
auto setWrapping(SamplerWrapping wrapping) -> RectangleTexture&
Set the same wrapping for all dimensions.
auto setWrapping(Magnum::SamplerWrapping wrapping) -> RectangleTexture&
auto setBorderColor(const Color4& color) -> RectangleTexture&
Set border color.
auto setBorderColor(const Vector4ui& color) -> RectangleTexture&
Set border color for integer texture.
auto setBorderColor(const Vector4i& color) -> RectangleTexture&
auto setMaxAnisotropy(Float anisotropy) -> RectangleTexture&
Set max anisotropy.
auto setSrgbDecode(bool decode) -> RectangleTexture&
Set sRGB decoding.
template<char r, char g, char b, char a>
auto setSwizzle() -> RectangleTexture&
Set component swizzle.
auto setCompareMode(SamplerCompareMode mode) -> RectangleTexture&
Set depth texture comparison mode.
auto setCompareFunction(SamplerCompareFunction function) -> RectangleTexture&
Set depth texture comparison function.
auto setDepthStencilMode(SamplerDepthStencilMode mode) -> RectangleTexture&
Set depth/stencil texture mode.
auto setStorage(TextureFormat internalFormat, const Vector2i& size) -> RectangleTexture&
Set storage.
auto imageSize() -> Vector2i
Texture image size.
void image(Image2D& image)
Read texture to an image.
auto image(Image2D&& image) -> Image2D
void image(const MutableImageView2D& image) new in 2019.10
Read texture to an image view.
void image(BufferImage2D& image, BufferUsage usage)
Read texture to a buffer image.
auto image(BufferImage2D&& image, BufferUsage usage) -> BufferImage2D
void compressedImage(CompressedImage2D& image)
Read compressed texture to an image.
auto compressedImage(CompressedImage2D&& image) -> CompressedImage2D
void compressedImage(const MutableCompressedImageView2D& image) new in 2019.10
Read compressed texture to an image view.
void compressedImage(CompressedBufferImage2D& image, BufferUsage usage)
Read compressed texture to a buffer image.
auto compressedImage(CompressedBufferImage2D&& image, BufferUsage usage) -> CompressedBufferImage2D
void subImage(const Range2Di& range, Image2D& image)
Read a texture range to an image.
auto subImage(const Range2Di& range, Image2D&& image) -> Image2D
void subImage(const Range2Di& range, const MutableImageView2D& image) new in 2019.10
Read a range of given texture mip level to an image view.
void subImage(const Range2Di& range, BufferImage2D& image, BufferUsage usage)
Read a texture range to a buffer image.
auto subImage(const Range2Di& range, BufferImage2D&& image, BufferUsage usage) -> BufferImage2D
void compressedSubImage(const Range2Di& range, CompressedImage2D& image)
Read a compressed texture range to an image.
auto compressedSubImage(const Range2Di& range, CompressedImage2D&& image) -> CompressedImage2D
void compressedSubImage(const Range2Di& range, const MutableCompressedImageView2D& image) new in 2019.10
Read a compressed texture range to an image view.
void compressedSubImage(const Range2Di& range, CompressedBufferImage2D& image, BufferUsage usage)
Read a compressed texture range to a buffer image.
auto compressedSubImage(const Range2Di& range, CompressedBufferImage2D&& image, BufferUsage usage) -> CompressedBufferImage2D
auto setImage(TextureFormat internalFormat, const ImageView2D& image) -> RectangleTexture&
Set image data.
auto setImage(TextureFormat internalFormat, BufferImage2D& image) -> RectangleTexture&
auto setImage(TextureFormat internalFormat, BufferImage2D&& image) -> RectangleTexture&
auto setCompressedImage(const CompressedImageView2D& image) -> RectangleTexture&
Set compressed image data.
auto setCompressedImage(CompressedBufferImage2D& image) -> RectangleTexture&
auto setCompressedImage(CompressedBufferImage2D&& image) -> RectangleTexture&
auto setSubImage(const Vector2i& offset, const ImageView2D& image) -> RectangleTexture&
Set image subdata.
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&
Set compressed image subdata.
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::GL::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::GL::RectangleTexture::compressedBlockSize(TextureFormat format)

Compressed block size.

See Texture::compressedBlockSize() for more information.

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

Compressed block data size.

See Texture::compressedBlockDataSize() for more information.

static RectangleTexture Magnum::GL::RectangleTexture::view(RectangleTexture& original, TextureFormat internalFormat) new in Git master

Create a view on another rectangle texture.

The internalFormat has to either match the format of original, or be compatible with it, such as having the same pixel size and other restrictions described in the OpenGL specification.

static RectangleTexture Magnum::GL::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::GL::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::GL::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. However note that this is a low-level and a potentially dangerous API, see the documentation of NoCreate for alternatives.

void Magnum::GL::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::GL::RectangleTexture::setMinificationFilter(SamplerFilter filter)

Set minification filter.

Returns Reference to self (for method chaining)

See Texture::setMinificationFilter() for more information. Initial value is SamplerFilter::Linear.

RectangleTexture& Magnum::GL::RectangleTexture::setMinificationFilter(Magnum::SamplerFilter filter)

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

RectangleTexture& Magnum::GL::RectangleTexture::setMagnificationFilter(SamplerFilter filter)

Set magnification filter.

Returns Reference to self (for method chaining)

See Texture::setMagnificationFilter() for more information.

RectangleTexture& Magnum::GL::RectangleTexture::setMagnificationFilter(Magnum::SamplerFilter filter)

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

RectangleTexture& Magnum::GL::RectangleTexture::setWrapping(const Math::Vector2<SamplerWrapping>& wrapping)

Set wrapping.

Returns Reference to self (for method chaining)

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

RectangleTexture& Magnum::GL::RectangleTexture::setWrapping(const Math::Vector2<Magnum::SamplerWrapping>& wrapping)

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

RectangleTexture& Magnum::GL::RectangleTexture::setWrapping(SamplerWrapping wrapping)

Set the same wrapping for all dimensions.

Returns Reference to self (for method chaining)

Same as calling setWrapping(const Math::Vector2<SamplerWrapping>&) with the same value for all dimensions.

RectangleTexture& Magnum::GL::RectangleTexture::setWrapping(Magnum::SamplerWrapping wrapping)

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

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

Set border color.

Returns Reference to self (for method chaining)

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

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

Set border color for integer texture.

Returns Reference to self (for method chaining)

See Texture::setBorderColor(const Vector4ui&) for more information.

RectangleTexture& Magnum::GL::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::GL::RectangleTexture::setMaxAnisotropy(Float anisotropy)

Set max anisotropy.

Returns Reference to self (for method chaining)

See Texture::setMaxAnisotropy() for more information.

RectangleTexture& Magnum::GL::RectangleTexture::setSrgbDecode(bool decode)

Set sRGB decoding.

Returns Reference to self (for method chaining)

See Texture::setSrgbDecode() for more information.

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

Set component swizzle.

Returns Reference to self (for method chaining)

See Texture::setSwizzle() for more information.

RectangleTexture& Magnum::GL::RectangleTexture::setCompareMode(SamplerCompareMode mode)

Set depth texture comparison mode.

Returns Reference to self (for method chaining)

See Texture::setCompareMode() for more information.

RectangleTexture& Magnum::GL::RectangleTexture::setCompareFunction(SamplerCompareFunction function)

Set depth texture comparison function.

Returns Reference to self (for method chaining)

See Texture::setCompareFunction() for more information.

RectangleTexture& Magnum::GL::RectangleTexture::setDepthStencilMode(SamplerDepthStencilMode mode)

Set depth/stencil texture mode.

Returns Reference to self (for method chaining)

See Texture::setDepthStencilMode() for more information.

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

Set storage.

Returns Reference to self (for method chaining)

See Texture::setStorage() for more information.

Vector2i Magnum::GL::RectangleTexture::imageSize()

Texture image size.

See Texture::imageSize() for more information.

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

Read texture to an image.

Behavior equivalent to Texture::image(Int, Image&), see its documentation for more information.

Image2D Magnum::GL::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::RGBA8Unorm});

void Magnum::GL::RectangleTexture::image(const MutableImageView2D& image) new in 2019.10

Read texture to an image view.

Compared to image(Image2D&) the function reads the pixels into the memory provided by image, expecting it's not nullptr and its size is the same as texture size. Any set of ImageFlags is allowed in image — e.g., it's possible to read a rectangle texture to an image marked as 1D array.

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

Read texture to a buffer image.

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

BufferImage2D Magnum::GL::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:

GL::BufferImage2D image = texture.image(
    {PixelFormat::RGBA8Unorm}, GL::BufferUsage::StaticRead);

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

Read compressed texture to an image.

Behavior equivalent to Texture::compressedImage(Int, CompressedImage&), see its documentation for more information.

CompressedImage2D Magnum::GL::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::GL::RectangleTexture::compressedImage(const MutableCompressedImageView2D& image) new in 2019.10

Read compressed texture to an image view.

Compared to compressedImage(CompressedImage2D&) the function reads the pixels into the memory provided by image, expecting it's not nullptr, its format is the same as texture format and its size is the same as texture size. Any set of ImageFlags is allowed in image — e.g., it's possible to read a rectangle texture to an image marked as 1D array.

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

Read compressed texture to a buffer image.

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

CompressedBufferImage2D Magnum::GL::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:

GL::CompressedBufferImage2D image = texture.compressedImage({},
    GL::BufferUsage::StaticRead);

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

Read a texture range to an image.

Behavior equivalent to Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&), see its documentation for more information.

Image2D Magnum::GL::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::RGBA8Unorm});

void Magnum::GL::RectangleTexture::subImage(const Range2Di& range, const MutableImageView2D& image) new in 2019.10

Read a range of given texture mip level to an image view.

Compared to subImage(const Range2Di&, Image2D&) the function reads the pixels into the memory provided by image, expecting it's not nullptr and its size is the same as range size. Any set of ImageFlags is allowed in image — e.g., it's possible to read a rectangle texture to an image marked as 1D array.

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

Read a texture range to a buffer image.

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

BufferImage2D Magnum::GL::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:

GL::BufferImage2D image = texture.subImage(range,
    {PixelFormat::RGBA8Unorm}, GL::BufferUsage::StaticRead);

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

Read a compressed texture range to an image.

Behavior equivalent to Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&), see its documentation for more information.

CompressedImage2D Magnum::GL::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, {});

void Magnum::GL::RectangleTexture::compressedSubImage(const Range2Di& range, const MutableCompressedImageView2D& image) new in 2019.10

Read a compressed texture range to an image view.

Compared to compressedSubImage(const Range2Di&, CompressedImage2D&) the function reads the pixels into the memory provided by image, expecting it's not nullptr, its format is the same as texture format and its size is the same as range size. Any set of ImageFlags is allowed in image — e.g., it's possible to read a rectangle texture to an image marked as 1D array.

CompressedBufferImage2D Magnum::GL::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:

GL::CompressedBufferImage2D image = texture.compressedSubImage(range, {},
    GL::BufferUsage::StaticRead);

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

Set image data.

Returns Reference to self (for method chaining)

Behavior equivalent to Texture::setImage(), see its documentation for more information. Any set of ImageFlags is allowed in image — e.g., it's possible to upload an image not marked as an array to an array texture.

RectangleTexture& Magnum::GL::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::GL::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::GL::RectangleTexture::setCompressedImage(const CompressedImageView2D& image)

Set compressed image data.

Returns Reference to self (for method chaining)

Behavior equivalent to Texture::setCompressedImage(), see its documentation for more information. Any set of ImageFlags is allowed in image — e.g., it's possible to upload an image not marked as an array to an array texture.

RectangleTexture& Magnum::GL::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::GL::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::GL::RectangleTexture::setSubImage(const Vector2i& offset, const ImageView2D& image)

Set image subdata.

Returns Reference to self (for method chaining)

Behavior equivalent to Texture::setSubImage(), see its documentation for more information. Any set of ImageFlags is allowed in image — e.g., it's possible to upload an image not marked as an array to an array texture.

RectangleTexture& Magnum::GL::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::GL::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::GL::RectangleTexture::setCompressedSubImage(const Vector2i& offset, const CompressedImageView2D& image)

Set compressed image subdata.

Returns Reference to self (for method chaining)

Behavior equivalent to Texture::setCompressedSubImage(), see its documentation for more information. Any set of ImageFlags is allowed in image — e.g., it's possible to upload an image not marked as an array to an array texture.

RectangleTexture& Magnum::GL::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::GL::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::GL::RectangleTexture::invalidateImage()

Invalidate texture.

See Texture::invalidateImage() for more information.

void Magnum::GL::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.