template<UnsignedInt dimensions>
Magnum::BufferImage class

Buffer image.

Stores image data in GPU memory. Interchangeable with Image, ImageView or Trade::ImageData.

Public types

enum (anonymous): UnsignedInt { Dimensions = dimensions }

Constructors, destructors, conversion operators

BufferImage(PixelStorage storage, PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage) explicit
Constructor.
BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage) explicit
BufferImage(PixelStorage storage, PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Buffer&& buffer, std::size_t dataSize) explicit noexcept
Construct from existing buffer.
BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Buffer&& buffer, std::size_t dataSize) explicit noexcept
BufferImage(PixelStorage storage, PixelFormat format, PixelType type)
Constructor.
BufferImage(PixelFormat format, PixelType type)
BufferImage(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
BufferImage(const BufferImage<dimensions>&) deleted
Copying is not allowed.
BufferImage(BufferImage<dimensions>&& other) noexcept
Move constructor.

Public functions

auto operator=(const BufferImage<dimensions>&) -> BufferImage<dimensions>& deleted
Copying is not allowed.
auto operator=(BufferImage<dimensions>&& other) -> BufferImage<dimensions>& noexcept
Move assignment.
auto storage() const -> PixelStorage
Storage of pixel data.
auto format() const -> PixelFormat
Format of pixel data.
auto type() const -> PixelType
Data type of pixel data.
auto pixelSize() const -> std::size_t
Pixel size (in bytes)
auto size() const -> VectorTypeFor<Dimensions, Int>
Image size.
auto dataProperties() const -> std::tuple<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>, std::size_t>
Image data properties.
auto dataSize() const -> std::size_t
Currently allocated data size.
auto buffer() -> Buffer&
Image buffer.
void setData(PixelStorage storage, PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage)
Set image data.
void setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage)
auto release() -> Buffer
Release the image buffer.

Enum documentation

template<UnsignedInt dimensions>
enum Magnum::BufferImage<dimensions>::(anonymous): UnsignedInt

Enumerators
Dimensions

Image dimension count

Function documentation

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(PixelStorage storage, PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage) explicit

Constructor.

Parameters
storage Storage of pixel data
format Format of pixel data
type Data type of pixel data
size Image size
data Image data
usage Image buffer usage

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Similar to the above, but uses default PixelStorage parameters.

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(PixelStorage storage, PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Buffer&& buffer, std::size_t dataSize) explicit noexcept

Construct from existing buffer.

Parameters
storage Storage of pixel data
format Format of pixel data
type Data type of pixel data
size Image size
buffer Buffer
dataSize Buffer data size

If dataSize is 0, the buffer is unconditionally reallocated on the first call to setData().

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Buffer&& buffer, std::size_t dataSize) explicit noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Similar to the above, but uses default PixelStorage parameters.

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(PixelStorage storage, PixelFormat format, PixelType type)

Constructor.

Parameters
storage Storage of pixel data
format Format of pixel data
type Data type of pixel data

Size is zero and buffer are empty, call setData() to fill the image with data or use *Texture::image()/ *Texture::subImage()/ *Framebuffer::read() to fill the image with data using storage settings.

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(PixelFormat format, PixelType type)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Similar to the above, but uses default PixelStorage parameters.

template<UnsignedInt dimensions>
Magnum::BufferImage<dimensions>::BufferImage(NoCreateT) explicit noexcept

Construct without creating the underlying OpenGL object.

The constructed instance is equivalent to moved-from state with PixelFormat::RGBA and PixelType::UnsignedByte. 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.

template<UnsignedInt dimensions>
std::size_t Magnum::BufferImage<dimensions>::pixelSize() const

Pixel size (in bytes)

template<UnsignedInt dimensions>
std::tuple<VectorTypeFor<dimensions, std::size_t>, VectorTypeFor<dimensions, std::size_t>, std::size_t> Magnum::BufferImage<dimensions>::dataProperties() const

Image data properties.

See PixelStorage::dataProperties() for more information.

template<UnsignedInt dimensions>
Buffer& Magnum::BufferImage<dimensions>::buffer()

Image buffer.

template<UnsignedInt dimensions>
void Magnum::BufferImage<dimensions>::setData(PixelStorage storage, PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage)

Set image data.

Parameters
storage Storage of pixel data
format Format of pixel data
type Data type of pixel data
size Image size
data Image data
usage Image buffer usage

Updates the image buffer with given data. Passing nullptr zero-sized data will not reallocate current storage, but expects that current data size is large enough for the new parameters.

template<UnsignedInt dimensions>
void Magnum::BufferImage<dimensions>::setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Similar to the above, but uses default PixelStorage parameters.

template<UnsignedInt dimensions>
Buffer Magnum::BufferImage<dimensions>::release()

Release the image buffer.

Releases the ownership of the image buffer and resets internal state to default.