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 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&&) noexcept defaulted
Move constructor.

Public functions

auto operator=(const RectangleTexture&) -> RectangleTexture& deleted
Copying is not allowed.
auto operator=(RectangleTexture&&) noexcept -> RectangleTexture& defaulted
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 Array2D<SamplerWrapping>& wrapping) -> RectangleTexture&
Set wrapping.
auto setWrapping(const Array2D<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.
auto setSRGBDecode(bool decode) -> RectangleTexture& deprecated
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 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)
Read range of given texture mip level to image.
auto subImage(const Range2Di& range, Image2D&& image) -> Image2D
void subImage(const Range2Di& range, BufferImage2D& image, BufferUsage usage)
Read range of given texture mip level to buffer image.
auto subImage(const Range2Di& range, BufferImage2D&& image, BufferUsage usage) -> BufferImage2D
void compressedSubImage(const Range2Di& range, CompressedImage2D& image)
Read range of given compressed texture mip level to image.
auto compressedSubImage(const Range2Di& range, CompressedImage2D&& image) -> CompressedImage2D
void compressedSubImage(const Range2Di& range, CompressedBufferImage2D& image, BufferUsage usage)
Read range of given compressed texture mip level to 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::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.

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

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

Set sRGB decoding.

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

See Texture::image(Int, Image&) 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(BufferImage2D& image, BufferUsage usage)

Read texture to 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 image.

See Texture::compressedImage(Int, CompressedImage&) 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(CompressedBufferImage2D& image, BufferUsage usage)

Read compressed texture to 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 range of given texture mip level to image.

See Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&) 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, 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::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);

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, {});

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)

See Texture::setImage() for more information.

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)

See Texture::setCompressedImage() for more information.

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)

See Texture::setSubImage() for more information.

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)

See Texture::setCompressedSubImage() for more information.

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.