Browse Source

GL: fill appropriate ImageFlags when using Texture::image() and friends.

Array texture and cubemap (array) subimage queries get
ImageFlag*D::Array, cubemap whole image ImageFlag3D::CubeMap, cubemap
array whole image get ImageFlag3D::CubeMap and ImageFlag3D::Array. No
flags are checked when uploading images or when downloading images to
views -- using an array texture as a cube map and vice versa is a valid
case, and others are probably also, so there's no point.

The flag restrictions will come into place when ImageFlag*D::YUp / YDown
etc. are a thing.
pull/578/head
Vladimír Vondruš 4 years ago
parent
commit
c9f1304cf7
  1. 40
      src/Magnum/GL/AbstractTexture.cpp
  2. 9
      src/Magnum/GL/AbstractTexture.h
  3. 13
      src/Magnum/GL/CubeMapTexture.cpp
  4. 104
      src/Magnum/GL/CubeMapTexture.h
  5. 76
      src/Magnum/GL/CubeMapTextureArray.h
  6. 57
      src/Magnum/GL/RectangleTexture.h
  7. 20
      src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp
  8. 31
      src/Magnum/GL/Test/CubeMapTextureGLTest.cpp
  9. 10
      src/Magnum/GL/Test/RectangleTextureGLTest.cpp
  10. 22
      src/Magnum/GL/Test/TextureArrayGLTest.cpp
  11. 46
      src/Magnum/GL/Test/TextureGLTest.cpp
  12. 66
      src/Magnum/GL/Texture.h
  13. 62
      src/Magnum/GL/TextureArray.h

40
src/Magnum/GL/AbstractTexture.cpp

@ -1718,7 +1718,7 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<dimensions>& image) {
template<UnsignedInt dimensions> void AbstractTexture::image(const GLint level, Image<dimensions>& image, const ImageFlags<dimensions> flags) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = Magnum::Implementation::imageDataSizeFor(image, size);
@ -1730,12 +1730,12 @@ template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getImageImplementation)(level, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data);
image = Image<dimensions>{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
image = Image<dimensions>{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), flags};
}
template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, Image<1>&);
template void MAGNUM_GL_EXPORT AbstractTexture::image<2>(GLint, Image<2>&);
template void MAGNUM_GL_EXPORT AbstractTexture::image<3>(GLint, Image<3>&);
template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, Image<1>&, ImageFlags1D);
template void MAGNUM_GL_EXPORT AbstractTexture::image<2>(GLint, Image<2>&, ImageFlags2D);
template void MAGNUM_GL_EXPORT AbstractTexture::image<3>(GLint, Image<3>&, ImageFlags3D);
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, const BasicMutableImageView<dimensions>& image) {
#ifndef CORRADE_NO_ASSERT
@ -1774,7 +1774,7 @@ template void MAGNUM_GL_EXPORT AbstractTexture::image<1>(GLint, BufferImage<1>&,
template void MAGNUM_GL_EXPORT AbstractTexture::image<2>(GLint, BufferImage<2>&, BufferUsage);
template void MAGNUM_GL_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, BufferUsage);
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedImage<dimensions>& image) {
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, CompressedImage<dimensions>& image, const ImageFlags<dimensions> flags) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
/* If the user-provided pixel storage doesn't tell us all properties about
@ -1798,12 +1798,12 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getCompressedImageImplementation)(level, data.size(), data);
image = CompressedImage<dimensions>{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
image = CompressedImage<dimensions>{image.storage(), CompressedPixelFormat(format), size, std::move(data), flags};
}
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedImage<1>&);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<2>(GLint, CompressedImage<2>&);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedImage<3>&);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedImage<1>&, ImageFlags1D);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<2>(GLint, CompressedImage<2>&, ImageFlags2D);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedImage<3>&, ImageFlags3D);
template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLint level, const BasicMutableCompressedImageView<dimensions>& image) {
#ifndef CORRADE_NO_ASSERT
@ -1874,7 +1874,7 @@ template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<1>(GLint, Compre
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<2>(GLint, CompressedBufferImage<2>&, BufferUsage);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedBufferImage<3>&, BufferUsage);
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image) {
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image, const ImageFlags<dimensions> flags) {
/* Reallocate only if needed */
const Math::Vector<dimensions, Int> size = range.size();
const std::size_t dataSize = Magnum::Implementation::imageDataSizeFor(image, size);
@ -1882,13 +1882,13 @@ template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint leve
if(data.size() < dataSize)
data = Containers::Array<char>{dataSize};
image = Image<dimensions>{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
image = Image<dimensions>{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), flags};
subImage(level, range, BasicMutableImageView<dimensions>(image));
}
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<1>(GLint, const Range1Di&, Image<1>&);
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<2>(GLint, const Range2Di&, Image<2>&);
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&, Image<3>&);
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<1>(GLint, const Range1Di&, Image<1>&, ImageFlags1D);
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<2>(GLint, const Range2Di&, Image<2>&, ImageFlags2D);
template void MAGNUM_GL_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&, Image<3>&, ImageFlags3D);
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, const BasicMutableImageView<dimensions>& image) {
CORRADE_ASSERT(image.data().data() != nullptr || !(Math::Vector<dimensions, Int>(range.size()).product()),
@ -1946,7 +1946,7 @@ template std::size_t MAGNUM_GL_EXPORT AbstractTexture::compressedSubImageSize<1>
template std::size_t MAGNUM_GL_EXPORT AbstractTexture::compressedSubImageSize<2>(TextureFormat format, const Math::Vector<2, Int>& size);
template std::size_t MAGNUM_GL_EXPORT AbstractTexture::compressedSubImageSize<3>(TextureFormat format, const Math::Vector<3, Int>& size);
template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image) {
template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image, const ImageFlags<dimensions> flags) {
createIfNotAlready();
const Math::Vector<dimensions, Int> size = range.size();
@ -1973,12 +1973,12 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), data.size(), data);
image = CompressedImage<dimensions>{CompressedPixelFormat(format), size, std::move(data)};
image = CompressedImage<dimensions>{CompressedPixelFormat(format), size, std::move(data), flags};
}
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<1>(GLint, const Range1Di&, CompressedImage<1>&);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<2>(GLint, const Range2Di&, CompressedImage<2>&);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<3>(GLint, const Range3Di&, CompressedImage<3>&);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<1>(GLint, const Range1Di&, CompressedImage<1>&, ImageFlags1D);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<2>(GLint, const Range2Di&, CompressedImage<2>&, ImageFlags2D);
template void MAGNUM_GL_EXPORT AbstractTexture::compressedSubImage<3>(GLint, const Range3Di&, CompressedImage<3>&, ImageFlags3D);
template<UnsignedInt dimensions> void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, const BasicMutableCompressedImageView<dimensions>& image) {
CORRADE_ASSERT(image.data().data() != nullptr || !(Math::Vector<dimensions, Int>(range.size()).product()),

9
src/Magnum/GL/AbstractTexture.h

@ -33,6 +33,7 @@
#include <Corrade/Containers/ArrayView.h>
#include "Magnum/DimensionTraits.h"
#include "Magnum/ImageFlags.h"
#include "Magnum/Tags.h"
#include "Magnum/GL/AbstractObject.h"
#include "Magnum/GL/GL.h"
@ -501,16 +502,16 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject {
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void image(GLint level, const BasicMutableImageView<dimensions>& image);
template<UnsignedInt dimensions> void image(GLint level, Image<dimensions>& image);
template<UnsignedInt dimensions> void image(GLint level, Image<dimensions>& image, ImageFlags<dimensions> flags);
template<UnsignedInt dimensions> void image(GLint level, BufferImage<dimensions>& image, BufferUsage usage);
template<UnsignedInt dimensions> void compressedImage(GLint level, const BasicMutableCompressedImageView<dimensions>& image);
template<UnsignedInt dimensions> void compressedImage(GLint level, CompressedImage<dimensions>& image);
template<UnsignedInt dimensions> void compressedImage(GLint level, CompressedImage<dimensions>& image, ImageFlags<dimensions> flags);
template<UnsignedInt dimensions> void compressedImage(GLint level, CompressedBufferImage<dimensions>& image, BufferUsage usage);
template<UnsignedInt dimensions> void subImage(GLint level, const RangeTypeFor<dimensions, Int>& range, const BasicMutableImageView<dimensions>& image);
template<UnsignedInt dimensions> void subImage(GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image);
template<UnsignedInt dimensions> void subImage(GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image, ImageFlags<dimensions> flags);
template<UnsignedInt dimensions> void subImage(GLint level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>& image, BufferUsage usage);
template<UnsignedInt dimensions> void compressedSubImage(GLint level, const RangeTypeFor<dimensions, Int>& range, const BasicMutableCompressedImageView<dimensions>& image);
template<UnsignedInt dimensions> void compressedSubImage(GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image);
template<UnsignedInt dimensions> void compressedSubImage(GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image, ImageFlags<dimensions> flags);
template<UnsignedInt dimensions> void compressedSubImage(GLint level, const RangeTypeFor<dimensions, Int>& range, CompressedBufferImage<dimensions>& image, BufferUsage usage);
#endif

13
src/Magnum/GL/CubeMapTexture.cpp

@ -81,7 +81,7 @@ void CubeMapTexture::image(const Int level, Image3D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getCubeImage3DImplementation)(level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data, image.storage());
image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
image = Image3D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), ImageFlag3D::CubeMap};
}
Image3D CubeMapTexture::image(const Int level, Image3D&& image) {
@ -152,7 +152,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getCompressedCubeImage3DImplementation)(level, size.xy(), dataOffsetSize.first, dataOffsetSize.second, data);
image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
image = CompressedImage3D{image.storage(), CompressedPixelFormat(format), size, std::move(data), ImageFlag3D::CubeMap};
}
CompressedImage3D CubeMapTexture::compressedImage(const Int level, CompressedImage3D&& image) {
@ -246,7 +246,7 @@ void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level,
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getCubeImageImplementation)(coordinate, level, size, pixelFormat(image.format()), pixelType(image.format(), image.formatExtra()), data.size(), data);
image = Image2D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data)};
image = Image2D{image.storage(), image.format(), image.formatExtra(), image.pixelSize(), size, std::move(data), ImageFlags2D{}};
}
Image2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, Image2D&& image) {
@ -311,7 +311,7 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
(this->*Context::current().state().texture.getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data);
image = CompressedImage2D{image.storage(), CompressedPixelFormat(format), size, std::move(data)};
image = CompressedImage2D{image.storage(), CompressedPixelFormat(format), size, std::move(data), ImageFlags2D{}};
}
CompressedImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedImage2D&& image) {
@ -422,7 +422,10 @@ void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range,
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
Context::current().state().renderer.applyPixelStoragePack(image.storage());
glGetCompressedTextureSubImage(_id, level, range.min().x(), range.min().y(), range.min().z(), range.size().x(), range.size().y(), range.size().z(), data.size(), data);
image = CompressedImage3D{CompressedPixelFormat(format), range.size(), std::move(data)};
/* Would be CubeMap if the whole image was queried, but then we'd have to
query the size and compare, which is extra work. So it's Array
instead. */
image = CompressedImage3D{CompressedPixelFormat(format), range.size(), std::move(data), ImageFlag3D::Array};
}
CompressedImage3D CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, CompressedImage3D&& image) {

104
src/Magnum/GL/CubeMapTexture.h

@ -556,9 +556,10 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
*
* Image parameters like format and type of pixel data are taken from
* given image, image size is taken from the texture using
* @ref imageSize(). The storage is not reallocated if it is large
* enough to contain the new data --- however if you want to read into
* existing memory or *ensure* a reallocation does not happen, use
* @ref imageSize(). Flags of @p image get reset to
* @ref ImageFlag3D::CubeMap. The storage is not reallocated if it is
* large enough to contain the new data --- however if you want to read
* into existing memory or *ensure* a reallocation does not happen, use
* @ref image(Int, const MutableImageView3D&) instead.
*
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
@ -595,6 +596,8 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* Compared to @ref image(Int, Image3D&) the function reads the pixels
* into the memory provided by @p image, expecting it's not
* @cpp nullptr @ce and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a cube map texture to an image marked as 2D array.
*/
void image(Int level, const MutableImageView3D& image);
@ -623,10 +626,11 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* @brief Read given mip level of a compressed texture to an image
*
* Compression format and data size are taken from the texture, image
* size is taken using @ref imageSize(). The storage is not reallocated
* if it is large enough to contain the new data --- however if you
* want to read into existing memory or *ensure* a reallocation does
* not happen, use @ref compressedImage(Int, const MutableCompressedImageView3D&)
* size is taken using @ref imageSize(). Flags of @p image get reset to
* @ref ImageFlag3D::CubeMap. The storage is not reallocated if it is
* large enough to contain the new data --- however if you want to read
* into existing memory or *ensure* a reallocation does not happen, use
* @ref compressedImage(Int, const MutableCompressedImageView3D&)
* instead.
* @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter} with
* @def_gl{TEXTURE_COMPRESSED_IMAGE_SIZE},
@ -657,6 +661,8 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a cube map texture to an image marked as 2D array.
*/
void compressedImage(Int level, const MutableCompressedImageView3D& image);
@ -688,10 +694,12 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
*
* Image parameters like format and type of pixel data are taken from
* given image, image size is taken from the texture using
* @ref imageSize(). The storage is not reallocated if it is large
* enough to contain the new data --- however if you want to read into
* existing memory or *ensure* a reallocation does not happen, use
* @ref image(CubeMapCoordinate, Int, const MutableImageView2D&)
* @ref imageSize(). Flags of @p image get cleared --- use
* @ref image(Int, Image3D&) instead if you want to get an image
* annotated with @ref ImageFlag3D::CubeMap. The storage is not
* reallocated if it is large enough to contain the new data ---
* however if you want to read into existing memory or *ensure* a
* reallocation does not happen, use @ref image(CubeMapCoordinate, Int, const MutableImageView2D&)
* instead.
*
* If @gl_extension{ARB,get_texture_sub_image} (part of OpenGL 4.5) is
@ -727,7 +735,9 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* Compared to @ref image(CubeMapCoordinate, Int, Image2D&) the
* function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce and its size is the same as size
* of given @p level.
* of given @p level. Any set of @ref ImageFlags is allowed in @p image
* --- e.g., it's possible to read a cube map texture face to an image
* marked as 1D array.
*/
void image(CubeMapCoordinate coordinate, Int level, const MutableImageView2D& image);
@ -755,10 +765,13 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* @brief Read given compressed texture mip level and coordinate to an image
*
* Compression format and data size are taken from the texture, image
* size is taken using @ref imageSize(). The storage is not reallocated
* if it is large enough to contain the new data --- however if you
* want to read into existing memory or *ensure* a reallocation does
* not happen, use @ref compressedImage(CubeMapCoordinate, Int, const MutableCompressedImageView2D&)
* size is taken using @ref imageSize(). Flags of @p image get cleared
* --- use @ref compressedImage(Int, CompressedImage3D&) instead if you
* want to get an image annotated with @ref ImageFlag3D::CubeMap. The
* storage is not reallocated if it is large enough to contain the new
* data --- however if you want to read into existing memory or
* *ensure* a reallocation does not happen, use
* @ref compressedImage(CubeMapCoordinate, Int, const MutableCompressedImageView2D&)
* instead.
*
* If @gl_extension{ARB,get_texture_sub_image} (part of OpenGL 4.5) is
@ -798,6 +811,9 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a cube map texture face to an image marked as 1D
* array.
*/
void compressedImage(CubeMapCoordinate coordinate, Int level, const MutableCompressedImageView2D& image);
@ -827,15 +843,22 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
/**
* @brief Read a range of given texture mip level to an image
*
* See @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&)
* for more information.
* Behavior mostly equivalent to
* @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array (as
* opposed to @ref ImageFlag3D::CubeMap when using
* @ref image(Int, Image3D&)).
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl Texture image queries are not available in OpenGL ES or
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
* for possible workarounds.
*/
void subImage(Int level, const Range3Di& range, Image3D& image) {
AbstractTexture::subImage<3>(level, range, image);
/* Would be CubeMap if the whole image was queried, but then we'd
have to query the size and compare, which is extra work. So it's
Array instead. */
AbstractTexture::subImage<3>(level, range, image, ImageFlag3D::Array);
}
/** @overload
@ -853,7 +876,9 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* Compared to @ref subImage(Int, const Range3Di&, Image3D&) the
* function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce and its size is the same as
* @p range size.
* @p range size. Any set of @ref ImageFlags is allowed in @p image ---
* e.g., it's possible to read a cube map texture to an image marked as
* 2D array.
*/
void subImage(Int level, const Range3Di& range, const MutableImageView3D& image) {
AbstractTexture::subImage<3>(level, range, image);
@ -884,8 +909,12 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
/**
* @brief Read a range of given compressed texture mip level to an image
*
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&)
* for more information.
* Behavior mostly equivalent to
* @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array (as
* opposed to @ref ImageFlag3D::CubeMap when using
* @ref compressedImage(Int, CompressedImage3D&)).
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -914,7 +943,9 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* Compared to @ref compressedSubImage(Int, const Range3Di&, CompressedImage3D&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as @p range size.
* texture format and its size is the same as @p range size. Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* read a cube map texture to an image marked as 2D array.
*/
void compressedSubImage(Int level, const Range3Di& range, const MutableCompressedImageView3D& image);
@ -949,7 +980,10 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* @brief @copybrief Texture::setImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setImage() for more information.
* Behavior equivalent to @ref Texture::setImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image
* marked as 1D array to a cube map face.
* @see @ref maxSize()
* @requires_gles30 Extension @gl_extension{EXT,unpack_subimage}/
* @gl_extension{NV,pack_subimage} in OpenGL ES 2.0 if
@ -995,7 +1029,10 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* @brief @copybrief Texture::setCompressedImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setCompressedImage() for more information.
* Behavior equivalent to @ref Texture::setCompressedImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image
* marked as 1D array to a cube map face.
* @see @ref maxSize()
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -1055,6 +1092,10 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
* not available, the texture is bound before the operation (if not
* already) and the image is uploaded slice by slice.
*
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image not marked as an array to an array
* texture.
* @see @ref setStorage(), @fn_gl2{TextureSubImage3D,TexSubImage3D},
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl_keyword{TexSubImage2D}
@ -1095,6 +1136,9 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* or compressed @ref Trade::ImageData3D
* @return Reference to self (for method chaining)
*
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image not marked as an array to an array
* texture.
* @see @ref setStorage(), @fn_gl2{CompressedTextureSubImage3D,CompressedTexSubImage3D}
* @requires_gl45 Extension @gl_extension{ARB,direct_state_access}
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
@ -1129,7 +1173,10 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* @brief @copybrief Texture::setSubImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setSubImage() for more information.
* Behavior equivalent to @ref Texture::setSubImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image
* marked as 1D array to a cube map face.
* @requires_gles30 Extension @gl_extension{EXT,unpack_subimage}/
* @gl_extension{NV,pack_subimage} in OpenGL ES 2.0 if
* @ref PixelStorage::rowLength() is set to a non-zero value.
@ -1162,7 +1209,10 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
* @brief @copybrief Texture::setCompressedSubImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setCompressedSubImage() for more information.
* Behavior equivalent to @ref Texture::setCompressedSubImage(), see
* its documentation for more information. Any set of @ref ImageFlags
* is allowed in @p image --- e.g., it's possible to upload an image
* marked as 1D array to a cube map face.
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
* @requires_gl Non-default @ref CompressedPixelStorage is not

76
src/Magnum/GL/CubeMapTextureArray.h

@ -481,13 +481,16 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
/**
* @brief Read given texture mip level to an image
*
* See @ref Texture::image(Int, Image&) for more information.
* Behavior mostly equivalent to @ref Texture::image(Int, Image&), see
* its documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array and
* @ref ImageFlag3D::CubeMap.
* @requires_gl Texture image queries are not available in OpenGL ES.
* See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
* for possible workarounds.
*/
void image(Int level, Image3D& image) {
AbstractTexture::image<3>(level, image);
AbstractTexture::image<3>(level, image, ImageFlag3D::Array|ImageFlag3D::CubeMap);
}
/** @overload
@ -505,6 +508,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* Compared to @ref image(Int, Image3D&) the function reads the pixels
* into the memory provided by @p image, expecting it's not
* @cpp nullptr @ce and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a cube map array texture to an image not marked as
* a cube map.
*/
void image(Int level, const MutableImageView3D& image) {
AbstractTexture::image<3>(level, image);
@ -534,8 +540,11 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
/**
* @brief Read given compressed texture mip level to an image
*
* See @ref Texture::compressedImage(Int, CompressedImage&) for more
* information.
* Behavior mostly equivalent to
* @ref Texture::compressedImage(Int, CompressedImage&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array and
* @ref ImageFlag3D::CubeMap.
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
* @requires_gl Texture image queries are not available in OpenGL ES.
@ -543,7 +552,7 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* for possible workarounds.
*/
void compressedImage(Int level, CompressedImage3D& image) {
AbstractTexture::compressedImage<3>(level, image);
AbstractTexture::compressedImage<3>(level, image, ImageFlag3D::Array|ImageFlag3D::CubeMap);
}
/** @overload
@ -562,6 +571,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a cube map array texture to an image not marked as
* a cube map.
*/
void compressedImage(Int level, const MutableCompressedImageView3D& image) {
AbstractTexture::compressedImage<3>(level, image);
@ -593,15 +605,22 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
/**
* @brief Read a range of given texture mip level to an image
*
* See @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&)
* for more information.
* Behavior mostly equivalent to
* @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array (but
* not @ref ImageFlag3D::CubeMap, which is only set when using
* @ref image(Int, Image3D&)).
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl Texture image queries are not available in OpenGL ES.
* See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
* for possible workarounds.
*/
void subImage(Int level, const Range3Di& range, Image3D& image) {
AbstractTexture::subImage<3>(level, range, image);
/* Would be also CubeMap if the whole image was queried, but then
we'd have to query the size and compare, which is extra work. So
it's Array always. */
AbstractTexture::subImage<3>(level, range, image, ImageFlag3D::Array);
}
/** @overload
@ -619,7 +638,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* Compared to @ref subImage(Int, const Range3Di&, Image3D&) the
* function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce and its size is the same as
* @p range size.
* @p range size. Any set of @ref ImageFlags is allowed in @p image ---
* e.g., it's possible to read a cube map array texture to an image not
* marked as a cube map.
*/
void subImage(Int level, const Range3Di& range, const MutableImageView3D& image) {
AbstractTexture::subImage<3>(level, range, image);
@ -650,8 +671,12 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
/**
* @brief Read a range of given compressed texture mip level to an image
*
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&)
* for more information.
* Behavior mostly equivalent to
* @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array (but
* not @ref ImageFlag3D::CubeMap, which is only set when using
* @ref compressedImage(Int, CompressedImage3D&)).
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -664,7 +689,10 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* for possible workarounds.
*/
void compressedSubImage(Int level, const Range3Di& range, CompressedImage3D& image) {
AbstractTexture::compressedSubImage<3>(level, range, image);
/* Would be also CubeMap if the whole image was queried, but then
we'd have to query the size and compare, which is extra work. So
it's Array always. */
AbstractTexture::compressedSubImage<3>(level, range, image, ImageFlag3D::Array);
}
/** @overload
@ -682,7 +710,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* Compared to @ref compressedSubImage(Int, const Range3Di&, CompressedImage3D&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as @p range size.
* texture format and its size is the same as @p range size. Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* read a cube map array texture to an image not marked as a cube map.
*/
void compressedSubImage(Int level, const Range3Di& range, const MutableCompressedImageView3D& image) {
AbstractTexture::compressedSubImage<3>(level, range, image);
@ -724,7 +754,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* Sets texture image data from three-dimensional image for all cube
* faces for all layers. Each group of 6 2D images is one cube map
* layer, thus Z coordinate of @p image size must be multiple of 6. The
* images are in order of (+X, -X, +Y, -Y, +Z, -Z).
* images are in order of (+X, -X, +Y, -Y, +Z, -Z). Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* upload an image marked as 2D array to a cube map array.
*
* See @ref Texture::setImage() for more information.
* @see @ref maxSize()
@ -760,7 +792,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
* Sets texture image data from three-dimensional image for all cube
* faces for all layers. Each group of 6 2D images is one cube map
* layer, thus Z coordinate of @p image size must be multiple of 6. The
* images are in order of (+X, -X, +Y, -Y, +Z, -Z).
* images are in order of (+X, -X, +Y, -Y, +Z, -Z). Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* upload an image marked as 2D array to a cube map array.
*
* See @ref Texture::setCompressedImage() for more information.
* @see @ref maxSize()
@ -799,7 +833,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Z coordinate is equivalent to layer * 6 + number of texture face,
* i.e. +X is @cpp 0 @ce and so on, in order of (+X, -X, +Y, -Y, +Z,
* -Z).
* -Z). Any set of @ref ImageFlags is allowed in @p image --- e.g.,
* it's possible to upload an image marked as 2D array to a cube map
* array.
*
* See @ref Texture::setSubImage() for more information.
*/
@ -825,7 +861,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Z coordinate is equivalent to layer * 6 + number of texture face,
* i.e. +X is @cpp 0 @ce and so on, in order of (+X, -X, +Y, -Y, +Z,
* -Z).
* -Z). Any set of @ref ImageFlags is allowed in @p image --- e.g.,
* it's possible to upload an image marked as 2D array to a cube map
* array.
*
* See @ref Texture::setCompressedSubImage() for more information.
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
@ -883,7 +921,9 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Z coordinate is equivalent to layer * 6 + number of texture face,
* i.e. +X is @cpp 0 @ce and so on, in order of (+X, -X, +Y, -Y, +Z,
* -Z).
* -Z). Any set of @ref ImageFlags is allowed in @p image --- e.g.,
* it's possible to upload an image marked as 2D array to a cube map
* array.
*
* See @ref Texture::invalidateSubImage() for more information.
*/

57
src/Magnum/GL/RectangleTexture.h

@ -368,10 +368,11 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
/**
* @brief Read texture to an image
*
* See @ref Texture::image(Int, Image&) for more information.
* Behavior equivalent to @ref Texture::image(Int, Image&), see its
* documentation for more information.
*/
void image(Image2D& image) {
AbstractTexture::image<2>(0, image);
AbstractTexture::image<2>(0, image, ImageFlags2D{});
}
/** @overload
@ -388,7 +389,9 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
*
* Compared to @ref image(Image2D&) the function reads the pixels into
* the memory provided by @p image, expecting it's not @cpp nullptr @ce
* and its size is the same as texture size.
* and its size is the same as texture size. Any set of @ref ImageFlags
* is allowed in @p image --- e.g., it's possible to read a rectangle
* texture to an image marked as 1D array.
*/
void image(const MutableImageView2D& image) {
AbstractTexture::image<2>(0, image);
@ -415,13 +418,13 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
/**
* @brief Read compressed texture to an image
*
* See @ref Texture::compressedImage(Int, CompressedImage&) for more
* information.
* Behavior equivalent to @ref Texture::compressedImage(Int, CompressedImage&),
* see its documentation for more information.
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
*/
void compressedImage(CompressedImage2D& image) {
AbstractTexture::compressedImage<2>(0, image);
AbstractTexture::compressedImage<2>(0, image, ImageFlags2D{});
}
/** @overload
@ -439,7 +442,9 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* Compared to @ref compressedImage(CompressedImage2D&) the function
* reads the pixels into the memory provided by @p image, expecting
* it's not @cpp nullptr @ce, its format is the same as texture format
* and its size is the same as texture size.
* and its size is the same as texture size. Any set of @ref ImageFlags
* is allowed in @p image --- e.g., it's possible to read a rectangle
* texture to an image marked as 1D array.
*/
void compressedImage(const MutableCompressedImageView2D& image) {
AbstractTexture::compressedImage<2>(0, image);
@ -468,12 +473,12 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
/**
* @brief Read a texture range to an image
*
* See @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&)
* for more information.
* Behavior equivalent to @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&),
* see its documentation for more information.
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
*/
void subImage(const Range2Di& range, Image2D& image) {
AbstractTexture::subImage<2>(0, range, image);
AbstractTexture::subImage<2>(0, range, image, ImageFlags2D{});
}
/** @overload
@ -491,6 +496,8 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* Compared to @ref subImage(const Range2Di&, Image2D&) the function
* reads the pixels into the memory provided by @p image, expecting
* it's not @cpp nullptr @ce and its size is the same as @p range size.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a rectangle texture to an image marked as 1D array.
*/
void subImage(const Range2Di& range, const MutableImageView2D& image) {
AbstractTexture::subImage<2>(0, range, image);
@ -518,8 +525,8 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
/**
* @brief Read a compressed texture range to an image
*
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&)
* for more information.
* Behavior equivalent to @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&),
* see its documentation for more information.
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -529,7 +536,7 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* set to non-zero values
*/
void compressedSubImage(const Range2Di& range, CompressedImage2D& image) {
AbstractTexture::compressedSubImage<2>(0, range, image);
AbstractTexture::compressedSubImage<2>(0, range, image, ImageFlags2D{});
}
/** @overload
@ -547,7 +554,9 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* Compared to @ref compressedSubImage(const Range2Di&, CompressedImage2D&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as @p range size.
* texture format and its size is the same as @p range size. Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* read a rectangle texture to an image marked as 1D array.
*/
void compressedSubImage(const Range2Di& range, const MutableCompressedImageView2D& image) {
AbstractTexture::compressedSubImage<2>(0, range, image);
@ -582,7 +591,10 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* @brief @copybrief Texture::setImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setImage() for more information.
* Behavior equivalent to @ref Texture::setImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image not
* marked as an array to an array texture.
* @see @ref maxSize()
* @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage()
* instead.
@ -613,7 +625,10 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* @brief @copybrief Texture::setCompressedImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setCompressedImage() for more information.
* Behavior equivalent to @ref Texture::setCompressedImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image not
* marked as an array to an array texture.
* @see @ref maxSize()
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -646,7 +661,10 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* @brief @copybrief Texture::setSubImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setSubImage() for more information.
* Behavior equivalent to @ref Texture::setSubImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image not
* marked as an array to an array texture.
*/
RectangleTexture& setSubImage(const Vector2i& offset, const ImageView2D& image) {
DataHelper<2>::setSubImage(*this, 0, offset, image);
@ -668,7 +686,10 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
* @brief @copybrief Texture::setCompressedSubImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setCompressedSubImage() for more information.
* Behavior equivalent to @ref Texture::setCompressedSubImage(), see
* its documentation for more information. Any set of @ref ImageFlags
* is allowed in @p image --- e.g., it's possible to upload an image
* not marked as an array to an array texture.
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
*/

20
src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp

@ -640,6 +640,7 @@ void CubeMapTextureArrayGLTest::image() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::CubeMap|ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -698,11 +699,13 @@ void CubeMapTextureArrayGLTest::imageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{PixelStorageData[testCaseInstanceId()].offset + 2*2*6*4};
MutableImageView3D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, data};
MutableImageView3D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, data, ImageFlag3D::Array};
texture.image(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -748,6 +751,7 @@ void CubeMapTextureArrayGLTest::compressedImage() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::CubeMap|ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorageData[testCaseInstanceId()].offset),
CompressedPixelStorageData[testCaseInstanceId()].data,
@ -826,11 +830,13 @@ void CubeMapTextureArrayGLTest::compressedImageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorageData[testCaseInstanceId()].offset + 6*16};
MutableCompressedImageView3D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, data};
MutableCompressedImageView3D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, data, ImageFlag3D::Array};
texture.compressedImage(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorageData[testCaseInstanceId()].offset),
CompressedPixelStorageData[testCaseInstanceId()].data,
@ -963,6 +969,7 @@ void CubeMapTextureArrayGLTest::subImageQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 4));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(SubPixelStorageData[testCaseInstanceId()].offset),
SubPixelStorageData[testCaseInstanceId()].data,
@ -984,11 +991,13 @@ void CubeMapTextureArrayGLTest::subImageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{SubPixelStorageData[testCaseInstanceId()].offset + 2*2*4*4};
MutableImageView3D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 4}, data};
MutableImageView3D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 4}, data, ImageFlag3D::Array};
texture.subImage(0, Range3Di::fromSize(Vector3i{1}, {2, 2, 4}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 4));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(SubPixelStorageData[testCaseInstanceId()].offset),
SubPixelStorageData[testCaseInstanceId()].data,
@ -1216,6 +1225,7 @@ void CubeMapTextureArrayGLTest::compressedSubImageQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedSubPixelStorageData[testCaseInstanceId()].offset),
CompressedSubPixelStorageData[testCaseInstanceId()].data,
@ -1243,11 +1253,13 @@ void CubeMapTextureArrayGLTest::compressedSubImageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedSubPixelStorageData[testCaseInstanceId()].offset + 4*16};
MutableCompressedImageView3D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 4}, data};
MutableCompressedImageView3D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 4}, data, ImageFlag3D::Array};
texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 1}, Vector3i{4}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedSubPixelStorageData[testCaseInstanceId()].offset),
CompressedSubPixelStorageData[testCaseInstanceId()].data,

31
src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

@ -861,6 +861,7 @@ void CubeMapTextureGLTest::image() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -872,6 +873,7 @@ void CubeMapTextureGLTest::image() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -883,6 +885,7 @@ void CubeMapTextureGLTest::image() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -945,11 +948,13 @@ void CubeMapTextureGLTest::imageQueryView() {
Containers::Array<char> data{PixelStorageData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorageData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.image(CubeMapCoordinate::PositiveY, 0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -1115,6 +1120,7 @@ void CubeMapTextureGLTest::subImageQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 1));
CORRADE_COMPARE_AS(Containers::arrayCast<const UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -1135,11 +1141,13 @@ void CubeMapTextureGLTest::subImageQueryView() {
Containers::Array<char> data{PixelStorageData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView3D image{PixelStorageData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 1}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 1}, data, ImageFlag3D::Array};
texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 1));
CORRADE_COMPARE_AS(Containers::arrayCast<const UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -1213,6 +1221,7 @@ void CubeMapTextureGLTest::compressedImage() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorageData[testCaseInstanceId()].offset),
CompressedPixelStorageData[testCaseInstanceId()].data,
@ -1295,11 +1304,13 @@ void CubeMapTextureGLTest::compressedImageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorageData[testCaseInstanceId()].offset + 16};
MutableCompressedImageView2D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
MutableCompressedImageView2D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data, ImageFlag2D::Array};
texture.compressedImage(CubeMapCoordinate::PositiveZ, 0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorageData[testCaseInstanceId()].offset),
CompressedPixelStorageData[testCaseInstanceId()].data,
@ -1653,11 +1664,13 @@ void CubeMapTextureGLTest::compressedSubImageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorageData[testCaseInstanceId()].offset + 16};
MutableCompressedImageView3D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 1}, data};
MutableCompressedImageView3D image{CompressedPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 1}, data, ImageFlag3D::Array};
texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1}));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorageData[testCaseInstanceId()].offset),
CompressedPixelStorageData[testCaseInstanceId()].data,
@ -1805,6 +1818,7 @@ void CubeMapTextureGLTest::image3D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::CubeMap);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && FullPixelStorageData[testCaseInstanceId()].storage != PixelStorage{},
@ -1861,11 +1875,13 @@ void CubeMapTextureGLTest::image3DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{FullPixelStorageData[testCaseInstanceId()].offset + 2*2*6*4};
MutableImageView3D image{FullPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, data};
MutableImageView3D image{FullPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, data, ImageFlag3D::Array};
texture.image(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && FullPixelStorageData[testCaseInstanceId()].storage != PixelStorage{},
@ -1957,6 +1973,7 @@ void CubeMapTextureGLTest::compressedImage3D() {
#endif
}
CORRADE_COMPARE(image.flags(), ImageFlag3D::CubeMap);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedFullPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{},
@ -2045,7 +2062,7 @@ void CubeMapTextureGLTest::compressedImage3DQueryView() {
}
Containers::Array<char> data{CompressedFullPixelStorageData[testCaseInstanceId()].offset + 16*6};
MutableCompressedImageView3D image{CompressedFullPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, data};
MutableCompressedImageView3D image{CompressedFullPixelStorageData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, data, ImageFlag3D::Array};
texture.compressedImage(0, image);
{
@ -2061,6 +2078,8 @@ void CubeMapTextureGLTest::compressedImage3DQueryView() {
#endif
}
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedFullPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{},

10
src/Magnum/GL/Test/RectangleTextureGLTest.cpp

@ -373,6 +373,7 @@ void RectangleTextureGLTest::image() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag2D{});
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -421,11 +422,13 @@ void RectangleTextureGLTest::imageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{PixelStorageData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
MutableImageView2D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.image(image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -513,6 +516,7 @@ void RectangleTextureGLTest::subImageQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag2D{});
CORRADE_COMPARE(image.size(), Vector2i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,
@ -534,11 +538,13 @@ void RectangleTextureGLTest::subImageQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{PixelStorageData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
MutableImageView2D image{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorageData[testCaseInstanceId()].offset),
PixelStorageData[testCaseInstanceId()].data,

22
src/Magnum/GL/Test/TextureArrayGLTest.cpp

@ -954,6 +954,7 @@ void TextureArrayGLTest::image1D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1002,11 +1003,13 @@ void TextureArrayGLTest::image1DQueryView() {
Containers::Array<char> data{PixelStorage1DData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorage1DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.image(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1094,6 +1097,7 @@ void TextureArrayGLTest::subImage1DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1116,11 +1120,13 @@ void TextureArrayGLTest::subImage1DQueryView() {
Containers::Array<char> data{PixelStorage1DData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorage1DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1212,6 +1218,7 @@ void TextureArrayGLTest::image2D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1391,6 +1398,7 @@ void TextureArrayGLTest::subImage2DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1413,11 +1421,13 @@ void TextureArrayGLTest::subImage2DQueryView() {
Containers::Array<char> data{PixelStorage2DData[testCaseInstanceId()].offset + 2*2*2*4};
MutableImageView3D image{PixelStorage2DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{2}, data, ImageFlag3D::Array};
texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1490,6 +1500,7 @@ void TextureArrayGLTest::compressedImage2D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2}));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
CompressedPixelStorage2DData[testCaseInstanceId()].data,
@ -1741,6 +1752,7 @@ void TextureArrayGLTest::compressedSubImage2DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2}));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
CompressedPixelStorage2DData[testCaseInstanceId()].data,
@ -1769,11 +1781,13 @@ void TextureArrayGLTest::compressedSubImage2DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorage2DData[testCaseInstanceId()].offset + 2*16};
MutableCompressedImageView3D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 2}, data};
MutableCompressedImageView3D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 2}, data, ImageFlag3D::Array};
texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 1}, {4, 4, 2}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2}));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
CompressedPixelStorage2DData[testCaseInstanceId()].data,

46
src/Magnum/GL/Test/TextureGLTest.cpp

@ -1429,6 +1429,7 @@ void TextureGLTest::image1D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags1D{});
CORRADE_COMPARE(image.size(), 2);
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1477,6 +1478,8 @@ void TextureGLTest::image1DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlags1D{});
CORRADE_COMPARE(image.size(), 2);
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1553,6 +1556,7 @@ void TextureGLTest::subImage1DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags1D{});
CORRADE_COMPARE(image.size(), 2);
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1578,6 +1582,8 @@ void TextureGLTest::subImage1DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlags1D{});
CORRADE_COMPARE(image.size(), 2);
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage1DData[testCaseInstanceId()].offset),
PixelStorage1DData[testCaseInstanceId()].data,
@ -1676,6 +1682,7 @@ void TextureGLTest::image2D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1727,11 +1734,13 @@ void TextureGLTest::image2DQueryView() {
Containers::Array<char> data{PixelStorage2DData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorage2DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.image(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1837,6 +1846,7 @@ void TextureGLTest::subImage2DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1857,11 +1867,13 @@ void TextureGLTest::subImage2DQueryView() {
Containers::Array<char> data{PixelStorage2DData[testCaseInstanceId()].offset + 2*2*4};
MutableImageView2D image{PixelStorage2DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, data, ImageFlag2D::Array};
texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage2DData[testCaseInstanceId()].offset),
PixelStorage2DData[testCaseInstanceId()].data,
@ -1928,6 +1940,7 @@ void TextureGLTest::compressedImage2D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
@ -2000,11 +2013,13 @@ void TextureGLTest::compressedImage2DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorage2DData[testCaseInstanceId()].offset + 1*16};
MutableCompressedImageView2D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
MutableCompressedImageView2D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data, ImageFlag2D::Array};
texture.compressedImage(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
@ -2142,6 +2157,7 @@ void TextureGLTest::compressedSubImage2DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags2D{});
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
CompressedPixelStorage2DData[testCaseInstanceId()].data,
@ -2167,11 +2183,13 @@ void TextureGLTest::compressedSubImage2DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorage2DData[testCaseInstanceId()].offset + 1*16};
MutableCompressedImageView2D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data};
MutableCompressedImageView2D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, data, ImageFlag2D::Array};
texture.compressedSubImage(0, Range2Di::fromSize({4, 0}, Vector2i{4}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag2D::Array);
CORRADE_COMPARE(image.size(), Vector2i{4});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(CompressedPixelStorage2DData[testCaseInstanceId()].offset),
CompressedPixelStorage2DData[testCaseInstanceId()].data,
@ -2235,6 +2253,7 @@ void TextureGLTest::image3D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags3D{});
CORRADE_COMPARE(image.size(), Vector3i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage3DData[testCaseInstanceId()].offset),
PixelStorage3DData[testCaseInstanceId()].data,
@ -2286,11 +2305,13 @@ void TextureGLTest::image3DQueryView() {
Containers::Array<char> data{PixelStorage3DData[testCaseInstanceId()].offset + 2*2*2*4};
MutableImageView3D image{PixelStorage3DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{2}, data, ImageFlag3D::Array};
texture.image(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i(2));
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage3DData[testCaseInstanceId()].offset),
PixelStorage3DData[testCaseInstanceId()].data,
@ -2405,6 +2426,7 @@ void TextureGLTest::subImage3DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags3D{});
CORRADE_COMPARE(image.size(), Vector3i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage3DData[testCaseInstanceId()].offset),
PixelStorage3DData[testCaseInstanceId()].data,
@ -2425,11 +2447,13 @@ void TextureGLTest::subImage3DQueryView() {
Containers::Array<char> data{PixelStorage3DData[testCaseInstanceId()].offset + 2*2*2*4};
MutableImageView3D image{PixelStorage3DData[testCaseInstanceId()].storage,
PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{2}, data};
PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{2}, data, ImageFlag3D::Array};
texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i{2});
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).exceptPrefix(PixelStorage3DData[testCaseInstanceId()].offset),
PixelStorage3DData[testCaseInstanceId()].data,
@ -2492,6 +2516,7 @@ void TextureGLTest::compressedImage3D() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags3D{});
CORRADE_COMPARE(image.size(), Vector3i{4});
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedPixelStorage3DData[testCaseInstanceId()].storage != CompressedPixelStorage{},
@ -2564,11 +2589,13 @@ void TextureGLTest::compressedImage3DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorage2DData[testCaseInstanceId()].offset + 64};
MutableCompressedImageView3D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBABptcUnorm, Vector3i{4}, data};
MutableCompressedImageView3D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBABptcUnorm, Vector3i{4}, data, ImageFlag3D::Array};
texture.compressedImage(0, image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), Vector3i{4});
{
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa) && CompressedPixelStorage3DData[testCaseInstanceId()].storage != CompressedPixelStorage{},
@ -2741,6 +2768,7 @@ void TextureGLTest::compressedSubImage3DQuery() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(image.flags(), ImageFlags3D{});
CORRADE_COMPARE(image.size(), (Vector3i{4}));
{
@ -2773,11 +2801,13 @@ void TextureGLTest::compressedSubImage3DQueryView() {
MAGNUM_VERIFY_NO_GL_ERROR();
Containers::Array<char> data{CompressedPixelStorage2DData[testCaseInstanceId()].offset + 64};
MutableCompressedImageView3D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBABptcUnorm, Vector3i{4}, data};
MutableCompressedImageView3D image{CompressedPixelStorage2DData[testCaseInstanceId()].storage, CompressedPixelFormat::RGBABptcUnorm, Vector3i{4}, data, ImageFlag3D::Array};
texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 0}, Vector3i{4}), image);
MAGNUM_VERIFY_NO_GL_ERROR();
/* Doesn't matter what flags are set, they stay untouched */
CORRADE_COMPARE(image.flags(), ImageFlag3D::Array);
CORRADE_COMPARE(image.size(), (Vector3i{4}));
{

66
src/Magnum/GL/Texture.h

@ -766,9 +766,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*
* Image parameters like format and type of pixel data are taken from
* given image, image size is taken from the texture using
* @ref imageSize(). The storage is not reallocated if it is large
* enough to contain the new data --- however if you want to read into
* existing memory or *ensure* a reallocation does not happen, use
* @ref imageSize(). @ref ImageFlags of @p image get cleared. The
* storage is not reallocated if it is large enough to contain the new
* data --- however if you want to read into existing memory or
* *ensure* a reallocation does not happen, use
* @ref image(Int, const BasicMutableImageView<dimensions>&) instead.
*
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
@ -788,7 +789,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* for possible workarounds.
*/
void image(Int level, Image<dimensions>& image) {
AbstractTexture::image<dimensions>(level, image);
AbstractTexture::image<dimensions>(level, image, ImageFlags<dimensions>{});
}
/** @overload
@ -806,6 +807,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* Compared to @ref image(Int, Image<dimensions>&) the function reads
* the pixels into the memory provided by @p image, expecting it's not
* @cpp nullptr @ce and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a 3D texture to an image marked as 2D array.
*/
void image(Int level, const BasicMutableImageView<dimensions>& image) {
AbstractTexture::image<dimensions>(level, image);
@ -844,10 +847,11 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param image Image where to put the compressed data
*
* Compression format and data size are taken from the texture, image
* size is taken using @ref imageSize(). The storage is not reallocated
* if it is large enough to contain the new data --- however if you
* want to read into existing memory or *ensure* a reallocation does
* not happen, use @ref compressedImage(Int, const BasicMutableCompressedImageView<dimensions>&)
* size is taken using @ref imageSize(). @ref ImageFlags of @p image
* get cleared. The storage is not reallocated if it is large enough to
* contain the new data --- however if you want to read into existing
* memory or *ensure* a reallocation does not happen, use
* @ref compressedImage(Int, const BasicMutableCompressedImageView<dimensions>&)
* instead.
*
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
@ -871,7 +875,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* for possible workarounds.
*/
void compressedImage(Int level, CompressedImage<dimensions>& image) {
AbstractTexture::compressedImage<dimensions>(level, image);
AbstractTexture::compressedImage<dimensions>(level, image, ImageFlags<dimensions>{});
}
/** @overload
@ -890,6 +894,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read a 3D texture to an image marked as 2D array.
*/
void compressedImage(Int level, const BasicMutableCompressedImageView<dimensions>& image) {
AbstractTexture::compressedImage<dimensions>(level, image);
@ -931,9 +937,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param image Image where to put the data
*
* Image parameters like format and type of pixel data are taken from
* given image. The storage is not reallocated if it is large enough to
* contain the new data --- however if you want to read into existing
* memory or *ensure* a reallocation does not happen, use
* given image. @ref ImageFlags of @p image get cleared. The storage is
* not reallocated if it is large enough to contain the new data ---
* however if you want to read into existing memory or *ensure* a
* reallocation does not happen, use
* @ref subImage(Int, const RangeTypeFor<dimensions, Int>&, const BasicMutableImageView<dimensions>&)
* instead.
*
@ -944,7 +951,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* WebGL. See @ref Framebuffer::read() for possible workaround.
*/
void subImage(Int level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image) {
AbstractTexture::subImage<dimensions>(level, range, image);
AbstractTexture::subImage<dimensions>(level, range, image, ImageFlags<dimensions>{});
}
/** @overload
@ -962,7 +969,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* Compared to @ref subImage(Int, const RangeTypeFor<dimensions, Int>&, Image<dimensions>&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce and its size is the same as
* @p range size.
* @p range size. Any set of @ref ImageFlags is allowed in @p image ---
* e.g., it's possible to read a 3D texture to an image marked as 2D
* array.
*/
void subImage(Int level, const RangeTypeFor<dimensions, Int>& range, const BasicMutableImageView<dimensions>& image) {
AbstractTexture::subImage<dimensions>(level, range, image);
@ -1001,10 +1010,11 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param range Range to read
* @param image Image where to put the compressed data
*
* Compression format and data size are taken from the texture. The
* storage is not reallocated if it is large enough to contain the new
* data --- however if you want to read into existing memory or
* *ensure* a reallocation does not happen, use
* Compression format and data size are taken from the texture.
* @ref ImageFlags of @p image get cleared. The storage is not
* reallocated if it is large enough to contain the new data ---
* however if you want to read into existing memory or *ensure* a
* reallocation does not happen, use
* @ref compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, const BasicMutableCompressedImageView<dimensions>&)
* instead.
* @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter},
@ -1026,7 +1036,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* for possible workarounds.
*/
void compressedSubImage(Int level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image) {
AbstractTexture::compressedSubImage<dimensions>(level, range, image);
AbstractTexture::compressedSubImage<dimensions>(level, range, image, ImageFlags<dimensions>{});
}
/** @overload
@ -1044,7 +1054,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* Compared to @ref compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage<dimensions>&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as @p range size.
* texture format and its size is the same as @p range size. Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* read a 3D texture to an image marked as 2D array.
*/
void compressedSubImage(Int level, const RangeTypeFor<dimensions, Int>& range, const BasicMutableCompressedImageView<dimensions>& image) {
AbstractTexture::compressedSubImage<dimensions>(level, range, image);
@ -1097,7 +1109,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* equivalent in @gl_extension{ARB,direct_state_access}, thus the texture
* needs to be bound to some texture unit before the operation.
*
* On OpenGL ES 2.0 and WebGL 1.0, if @ref PixelStorage::skip() is set,
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image marked as 2D array to a 3D texture. On
* OpenGL ES 2.0 and WebGL 1.0, if @ref PixelStorage::skip() is set,
* the functionality is emulated by adjusting the data pointer.
* @see @ref maxSize(), @ref Framebuffer::copyImage(), @fn_gl{PixelStore},
* then @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
@ -1158,6 +1172,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* also has no equivalent in @gl_extension{ARB,direct_state_access},
* thus the texture needs to be bound to some texture unit before the
* operation.
*
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image marked as 2D array to a 3D texture.
* @see @ref maxSize(), @fn_gl{PixelStore}, then @fn_gl{ActiveTexture},
* @fn_gl{BindTexture} and @fn_gl_keyword{CompressedTexImage1D} /
* @fn_gl_keyword{CompressedTexImage2D} /
@ -1221,7 +1238,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* not available, the texture is bound before the operation (if not
* already).
*
* On OpenGL ES 2.0 and WebGL 1.0, if @ref PixelStorage::skip() is set,
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image marked as 2D array to a 3D texture. On
* OpenGL ES 2.0 and WebGL 1.0, if @ref PixelStorage::skip() is set,
* the functionality is emulated by adjusting the data pointer.
* @see @ref setStorage(), @ref Framebuffer::copySubImage(),
* @fn_gl{PixelStore}, @fn_gl2_keyword{TextureSubImage1D,TexSubImage1D} /
@ -1282,6 +1301,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
* not available, the texture is bound before the operation (if not
* already).
*
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image marked as 2D array to a 3D texture.
* @see @ref setStorage(), @fn_gl{PixelStore},
* @fn_gl2_keyword{CompressedTextureSubImage1D,CompressedTexSubImage1D} /
* @fn_gl2_keyword{CompressedTextureSubImage2D,CompressedTexSubImage2D} /

62
src/Magnum/GL/TextureArray.h

@ -518,13 +518,15 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
/**
* @brief Read given texture mip level to an image
*
* See @ref Texture::image(Int, Image&) for more information.
* Behavior mostly equivalent to @ref Texture::image(Int, Image&), see
* its documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array "ImageFlag*D::Array".
* @requires_gl Texture image queries are not available in OpenGL ES or
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
* for possible workarounds.
*/
void image(Int level, Image<dimensions+1>& image) {
AbstractTexture::image<dimensions+1>(level, image);
AbstractTexture::image<dimensions+1>(level, image, ImageFlag<dimensions+1>::Array);
}
/** @overload
@ -542,6 +544,9 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* Compared to @ref image(Int, Image<dimensions+1>&) the function reads
* the pixels into the memory provided by @p image, expecting it's not
* @cpp nullptr @ce and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read an array texture to an image not marked as an
* array.
*/
void image(Int level, const BasicMutableImageView<dimensions+1>& image) {
AbstractTexture::image<dimensions+1>(level, image);
@ -571,8 +576,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
/**
* @brief Read given compressed texture mip level to an image
*
* See @ref Texture::compressedImage(Int, CompressedImage&) for more
* information.
* Behavior mostly equivalent to
* @ref Texture::compressedImage(Int, CompressedImage&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array "ImageFlag*D::Array".
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
* @requires_gl Texture image queries are not available in OpenGL ES or
@ -580,7 +587,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* for possible workarounds.
*/
void compressedImage(Int level, CompressedImage<dimensions+1>& image) {
AbstractTexture::compressedImage<dimensions+1>(level, image);
AbstractTexture::compressedImage<dimensions+1>(level, image, ImageFlag<dimensions+1>::Array);
}
/** @overload
@ -599,6 +606,9 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as size of given @p level.
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to read an array texture to an image not marked as an
* array.
*/
void compressedImage(Int level, const BasicMutableCompressedImageView<dimensions+1>& image) {
AbstractTexture::compressedImage<dimensions+1>(level, image);
@ -630,15 +640,17 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
/**
* @brief Read a range of given texture mip level to an image
*
* See @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&)
* for more information.
* Behavior mostly equivalent to
* @ref Texture::subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array "ImageFlag*D::Array".
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl Texture image queries are not available in OpenGL ES or
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
* for possible workarounds.
*/
void subImage(Int level, const RangeTypeFor<dimensions+1, Int>& range, Image<dimensions+1>& image) {
AbstractTexture::subImage<dimensions+1>(level, range, image);
AbstractTexture::subImage<dimensions+1>(level, range, image, ImageFlag<dimensions+1>::Array);
}
/** @overload
@ -656,7 +668,9 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* Compared to @ref subImage(Int, const RangeTypeFor<dimensions+1, Int>&, Image<dimensions+1>&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce and its size is the same as
* @p range size.
* @p range size. Any set of @ref ImageFlags is allowed in @p image ---
* e.g., it's possible to read an array texture to an image not marked
* as an array.
*/
void subImage(Int level, const RangeTypeFor<dimensions+1, Int>& range, const BasicMutableImageView<dimensions+1>& image) {
AbstractTexture::subImage<dimensions+1>(level, range, image);
@ -687,8 +701,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
/**
* @brief Read a range of given compressed texture mip level to an image
*
* See @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&)
* for more information.
* Behavior mostly equivalent to
* @ref Texture::compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedImage&), see its
* documentation for more information. In this case however,
* @ref ImageFlags of @p image get set to @ref ImageFlag3D::Array "ImageFlag*D::Array".
* @requires_gl45 Extension @gl_extension{ARB,get_texture_sub_image}
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -701,7 +717,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* for possible workarounds.
*/
void compressedSubImage(Int level, const RangeTypeFor<dimensions+1, Int>& range, CompressedImage<dimensions+1>& image) {
AbstractTexture::compressedSubImage<dimensions+1>(level, range, image);
AbstractTexture::compressedSubImage<dimensions+1>(level, range, image, ImageFlag<dimensions+1>::Array);
}
/** @overload
@ -719,7 +735,9 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* Compared to @ref compressedSubImage(Int, const RangeTypeFor<dimensions+1, Int>&, CompressedImage<dimensions+1>&)
* the function reads the pixels into the memory provided by @p image,
* expecting it's not @cpp nullptr @ce, its format is the same as
* texture format and its size is the same as @p range size.
* texture format and its size is the same as @p range size. Any set of
* @ref ImageFlags is allowed in @p image --- e.g., it's possible to
* read an array texture to an image not marked as an array.
*/
void compressedSubImage(Int level, const RangeTypeFor<dimensions+1, Int>& range, const BasicMutableCompressedImageView<dimensions+1>& image) {
AbstractTexture::compressedSubImage<dimensions+1>(level, range, image);
@ -758,7 +776,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* @brief @copybrief Texture::setImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setImage() for more information.
* Behavior equivalent to @ref Texture::setImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image not
* marked as an array to an array texture.
* @see @ref maxSize()
* @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage()
* instead.
@ -789,7 +810,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* @brief @copybrief Texture::setCompressedImage()
* @return Reference to self (for method chaining)
*
* See @ref Texture::setCompressedImage() for more information.
* Behavior equivalent to @ref Texture::setCompressedImage(), see its
* documentation for more information. Any set of @ref ImageFlags is
* allowed in @p image --- e.g., it's possible to upload an image not
* marked as an array to an array texture.
* @see @ref maxSize()
* @requires_gl42 Extension @gl_extension{ARB,compressed_texture_pixel_storage}
* for non-default @ref CompressedPixelStorage
@ -839,6 +863,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
* not available, the texture is bound before the operation (if not
* already).
*
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image not marked as an array to an array
* texture.
* @see @ref setStorage(), @fn_gl{PixelStore}, then
* @fn_gl2_keyword{TextureSubImage2D,TexSubImage2D}/
* @fn_gl2_keyword{TextureSubImage3D,TexSubImage3D},
@ -872,6 +900,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* If @gl_extension{ARB,direct_state_access} (part of OpenGL 4.5) is
* not available, the texture is bound before the operation (if not
* already).
*
* Any set of @ref ImageFlags is allowed in @p image --- e.g., it's
* possible to upload an image not marked as an array to an array
* texture.
* @see @ref setStorage(), @fn_gl{PixelStore}, then
* @fn_gl2_keyword{CompressedTextureSubImage2D,CompressedTexSubImage2D}/
* @fn_gl2_keyword{CompressedTextureSubImage3D,CompressedTexSubImage3D},

Loading…
Cancel
Save