Browse Source

Pixel storage support, part 2: renamed ColorFormat to PixelFormat etc.

Yeah, sorry, I know, the enums are renamed for second or third time in a
row, first they were Image::Format, then ImageFormat, then ColorFormat
and now PixelFormat. But this time it's final and last time they are
renamed and now everything is finally consistent:

 * ColorFormat::DepthComponent -- depth is not a color, thus
   PixelFormat::DepthComponent makes a lot more sense.
 * There will be PixelStorage classes, which will be stored in images
   alonside PixelFormat/PixelType enums, making everything nicely
   aligned.
 * The GL documentation about glTexImage2D() etc. denotes the <format>
   and <type> parameters as format and type of *pixel* data, so now we
   are _finally_ consistent with the official naming.

I wonder why did I not choose PixelFormat originally. Anyway, the old
<Magnum/ColorFormat.h> header, ColorFormat, ColorType and
CompressedColorFormat types are now aliases to the new ones, are marked
as deprecated and will be removed in some future release (as always, I'm
waiting at least six months before removing the deprecated
functionality).
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
d96e1e3541
  1. 10
      doc/generated/shaders.cpp
  2. 4
      src/Magnum/AbstractFramebuffer.cpp
  3. 8
      src/Magnum/AbstractFramebuffer.h
  4. 134
      src/Magnum/AbstractTexture.cpp
  5. 48
      src/Magnum/AbstractTexture.h
  6. 10
      src/Magnum/BufferImage.cpp
  7. 22
      src/Magnum/BufferImage.h
  8. 5
      src/Magnum/CMakeLists.txt
  9. 1188
      src/Magnum/ColorFormat.h
  10. 28
      src/Magnum/CubeMapTexture.cpp
  11. 34
      src/Magnum/CubeMapTexture.h
  12. 10
      src/Magnum/CubeMapTextureArray.h
  13. 4
      src/Magnum/Image.cpp
  14. 22
      src/Magnum/Image.h
  15. 20
      src/Magnum/ImageView.h
  16. 2
      src/Magnum/Implementation/FramebufferState.h
  17. 20
      src/Magnum/Implementation/TextureState.h
  18. 13
      src/Magnum/Magnum.h
  19. 20
      src/Magnum/PixelFormat.cpp
  20. 1206
      src/Magnum/PixelFormat.h
  21. 104
      src/Magnum/PixelStorage.cpp
  22. 4
      src/Magnum/PixelStorage.h
  23. 10
      src/Magnum/RectangleTexture.h
  24. 46
      src/Magnum/Test/BufferImageGLTest.cpp
  25. 44
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  26. 66
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  27. 32
      src/Magnum/Test/FormatTest.cpp
  28. 16
      src/Magnum/Test/FramebufferGLTest.cpp
  29. 60
      src/Magnum/Test/ImageTest.cpp
  30. 22
      src/Magnum/Test/ImageViewTest.cpp
  31. 86
      src/Magnum/Test/MeshGLTest.cpp
  32. 20
      src/Magnum/Test/PixelStorageTest.cpp
  33. 30
      src/Magnum/Test/RectangleTextureGLTest.cpp
  34. 74
      src/Magnum/Test/TextureArrayGLTest.cpp
  35. 116
      src/Magnum/Test/TextureGLTest.cpp
  36. 30
      src/Magnum/Text/DistanceFieldGlyphCache.cpp
  37. 16
      src/Magnum/Texture.h
  38. 10
      src/Magnum/TextureArray.h
  39. 4
      src/Magnum/TextureFormat.h
  40. 12
      src/Magnum/TextureTools/distancefieldconverter.cpp
  41. 6
      src/Magnum/Trade/ImageData.cpp
  42. 16
      src/Magnum/Trade/ImageData.h
  43. 4
      src/Magnum/Trade/Test/AbstractImageConverterTest.cpp
  44. 46
      src/Magnum/Trade/Test/ImageDataTest.cpp
  45. 4
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp
  46. 6
      src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp
  47. 16
      src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp
  48. 24
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp
  49. 6
      src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h
  50. 22
      src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp
  51. 20
      src/MagnumPlugins/TgaImporter/TgaImporter.cpp
  52. 6
      src/MagnumPlugins/TgaImporter/TgaImporter.h

10
doc/generated/shaders.cpp

@ -40,8 +40,12 @@
#include <Magnum/Framebuffer.h>
#include <Magnum/Image.h>
#include <Magnum/Mesh.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/Renderbuffer.h>
#include <Magnum/RenderbufferFormat.h>
#include <Magnum/Renderer.h>
#include <Magnum/Texture.h>
#include <Magnum/TextureFormat.h>
#include <Magnum/MeshTools/Compile.h>
#include <Magnum/MeshTools/Interleave.h>
#include <Magnum/Primitives/Square.h>
@ -59,10 +63,6 @@
#include <Magnum/Trade/MeshData2D.h>
#include <Magnum/Trade/MeshData3D.h>
#include <Magnum/Trade/AbstractImporter.h>
#include <Magnum/Renderer.h>
#include <Magnum/ColorFormat.h>
#include <Magnum/Texture.h>
#include <Magnum/TextureFormat.h>
#include "configure.h"
@ -131,7 +131,7 @@ int ShaderVisualizer::exec() {
std::string filename = (this->*fun)();
AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA, PixelType::UnsignedByte});
converter->exportToFile(result, Utility::Directory::join("../", "shaders-" + filename));
}

4
src/Magnum/AbstractFramebuffer.cpp

@ -454,12 +454,12 @@ void AbstractFramebuffer::readBufferImplementationDSAEXT(GLenum buffer) {
}
#endif
void AbstractFramebuffer::readImplementationDefault(const Range2Di& rectangle, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
void AbstractFramebuffer::readImplementationDefault(const Range2Di& rectangle, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) {
glReadPixels(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), data);
}
#ifndef MAGNUM_TARGET_WEBGL
void AbstractFramebuffer::readImplementationRobustness(const Range2Di& rectangle, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
void AbstractFramebuffer::readImplementationRobustness(const Range2Di& rectangle, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
#ifndef MAGNUM_TARGET_GLES
glReadnPixelsARB(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data);
#elif !defined(CORRADE_TARGET_NACL)

8
src/Magnum/AbstractFramebuffer.h

@ -327,7 +327,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = framebuffer.read(framebuffer.viewport(), {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image2D image = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image2D read(const Range2Di& rectangle, Image2D&& image);
@ -364,7 +364,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = framebuffer.read(framebuffer.viewport(), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage2D image = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage2D read(const Range2Di& rectangle, BufferImage2D&& image, BufferUsage usage);
@ -455,9 +455,9 @@ class MAGNUM_EXPORT AbstractFramebuffer {
void MAGNUM_LOCAL readBufferImplementationDSAEXT(GLenum buffer);
#endif
static void MAGNUM_LOCAL readImplementationDefault(const Range2Di& rectangle, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static void MAGNUM_LOCAL readImplementationDefault(const Range2Di& rectangle, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
#ifndef MAGNUM_TARGET_WEBGL
static void MAGNUM_LOCAL readImplementationRobustness(const Range2Di& rectangle, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static void MAGNUM_LOCAL readImplementationRobustness(const Range2Di& rectangle, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
#endif
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*);

134
src/Magnum/AbstractTexture.cpp

@ -31,10 +31,10 @@
#include "Magnum/BufferImage.h"
#endif
#include "Magnum/Array.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h"
@ -471,7 +471,7 @@ void AbstractTexture::bindInternal() {
}
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) {
PixelFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) {
switch(internalFormat) {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case TextureFormat::Red:
@ -496,7 +496,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedR11Eac:
case TextureFormat::CompressedSignedR11Eac:
#endif
return ColorFormat::Red;
return PixelFormat::Red;
#endif
#ifndef MAGNUM_TARGET_GLES2
@ -506,7 +506,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::R16I:
case TextureFormat::R32UI:
case TextureFormat::R32I:
return ColorFormat::RedInteger;
return PixelFormat::RedInteger;
#endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
@ -532,7 +532,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedRG11Eac:
case TextureFormat::CompressedSignedRG11Eac:
#endif
return ColorFormat::RG;
return PixelFormat::RG;
#endif
#ifndef MAGNUM_TARGET_GLES2
@ -542,7 +542,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RG16I:
case TextureFormat::RG32UI:
case TextureFormat::RG32I:
return ColorFormat::RGInteger;
return PixelFormat::RGInteger;
#endif
case TextureFormat::RGB:
@ -592,7 +592,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedSRGB8Etc2:
#endif
case TextureFormat::CompressedRGBS3tcDxt1:
return ColorFormat::RGB;
return PixelFormat::RGB;
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGB8UI:
@ -601,7 +601,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RGB16I:
case TextureFormat::RGB32UI:
case TextureFormat::RGB32I:
return ColorFormat::RGBInteger;
return PixelFormat::RGBInteger;
#endif
case TextureFormat::RGBA:
@ -680,7 +680,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedRGBAAstc12x12:
case TextureFormat::CompressedSRGB8Alpha8Astc12x12:
#endif
return ColorFormat::RGBA;
return PixelFormat::RGBA;
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGBA8UI:
@ -690,14 +690,14 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RGBA32UI:
case TextureFormat::RGBA32I:
case TextureFormat::RGB10A2UI:
return ColorFormat::RGBAInteger;
return PixelFormat::RGBAInteger;
#endif
#ifdef MAGNUM_TARGET_GLES2
case TextureFormat::Luminance:
return ColorFormat::Luminance;
return PixelFormat::Luminance;
case TextureFormat::LuminanceAlpha:
return ColorFormat::LuminanceAlpha;
return PixelFormat::LuminanceAlpha;
#endif
case TextureFormat::DepthComponent:
@ -711,11 +711,11 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::DepthComponent32F:
#endif
return ColorFormat::DepthComponent;
return PixelFormat::DepthComponent;
#ifndef MAGNUM_TARGET_WEBGL
case TextureFormat::StencilIndex8:
return ColorFormat::StencilIndex;
return PixelFormat::StencilIndex;
#endif
case TextureFormat::DepthStencil:
@ -725,13 +725,13 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::Depth32FStencil8:
#endif
return ColorFormat::DepthStencil;
return PixelFormat::DepthStencil;
}
CORRADE_ASSERT_UNREACHABLE();
}
ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) {
PixelType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) {
switch(internalFormat) {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case TextureFormat::Red:
@ -820,7 +820,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::CompressedRGBAAstc12x12:
case TextureFormat::CompressedSRGB8Alpha8Astc12x12:
#endif
return ColorType::UnsignedByte;
return PixelType::UnsignedByte;
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::R8Snorm:
@ -835,7 +835,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::CompressedSignedRedRgtc1:
case TextureFormat::CompressedSignedRGRgtc2:
#endif
return ColorType::Byte;
return PixelType::Byte;
#endif
#ifndef MAGNUM_TARGET_GLES
@ -857,7 +857,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGBA12: /**< @todo really? */
#endif
return ColorType::UnsignedShort;
return PixelType::UnsignedShort;
#ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES
@ -870,7 +870,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::RG16I:
case TextureFormat::RGB16I:
case TextureFormat::RGBA16I:
return ColorType::Short;
return PixelType::Short;
#endif
#ifndef MAGNUM_TARGET_GLES2
@ -878,19 +878,19 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::RG16F:
case TextureFormat::RGB16F:
case TextureFormat::RGBA16F:
return ColorType::HalfFloat;
return PixelType::HalfFloat;
case TextureFormat::R32UI:
case TextureFormat::RG32UI:
case TextureFormat::RGB32UI:
case TextureFormat::RGBA32UI:
return ColorType::UnsignedInt;
return PixelType::UnsignedInt;
case TextureFormat::R32I:
case TextureFormat::RG32I:
case TextureFormat::RGB32I:
case TextureFormat::RGBA32I:
return ColorType::Int;
return PixelType::Int;
case TextureFormat::R32F:
case TextureFormat::RG32F:
@ -900,24 +900,24 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::CompressedRGBBptcUnsignedFloat:
case TextureFormat::CompressedRGBBptcSignedFloat:
#endif
return ColorType::Float;
return PixelType::Float;
#endif
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::R3B3G2:
return ColorType::UnsignedByte332;
return PixelType::UnsignedByte332;
case TextureFormat::RGB4:
return ColorType::UnsignedShort4444;
return PixelType::UnsignedShort4444;
#endif
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGB5:
#endif
case TextureFormat::RGB5A1:
return ColorType::UnsignedShort5551;
return PixelType::UnsignedShort5551;
case TextureFormat::RGB565:
return ColorType::UnsignedShort565;
return PixelType::UnsignedShort565;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
@ -927,19 +927,19 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGB10A2UI:
#endif
return ColorType::UnsignedInt2101010Rev; /**< @todo Rev for all? */
return PixelType::UnsignedInt2101010Rev; /**< @todo Rev for all? */
#endif
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::R11FG11FB10F:
return ColorType::UnsignedInt10F11F11FRev;
return PixelType::UnsignedInt10F11F11FRev;
case TextureFormat::RGB9E5:
return ColorType::UnsignedInt5999Rev;
return PixelType::UnsignedInt5999Rev;
#endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case TextureFormat::DepthComponent16:
return ColorType::UnsignedShort;
return PixelType::UnsignedShort;
#endif
case TextureFormat::DepthComponent:
@ -949,27 +949,27 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
#ifndef MAGNUM_TARGET_WEBGL
case TextureFormat::DepthComponent32:
#endif
return ColorType::UnsignedInt;
return PixelType::UnsignedInt;
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::DepthComponent32F:
return ColorType::Float;
return PixelType::Float;
#endif
#ifndef MAGNUM_TARGET_WEBGL
case TextureFormat::StencilIndex8:
return ColorType::UnsignedByte;
return PixelType::UnsignedByte;
#endif
case TextureFormat::DepthStencil:
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case TextureFormat::Depth24Stencil8:
#endif
return ColorType::UnsignedInt248;
return PixelType::UnsignedInt248;
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::Depth32FStencil8:
return ColorType::Float32UnsignedInt248Rev;
return PixelType::Float32UnsignedInt248Rev;
#endif
}
@ -1113,8 +1113,8 @@ void AbstractTexture::getLevelParameterImplementationDSAEXT(GLint level, GLenum
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat);
const PixelFormat format = imageFormatForInternalFormat(internalFormat);
const PixelType type = imageTypeForInternalFormat(internalFormat);
for(GLsizei level = 0; level != levels; ++level)
DataHelper<1>::setImage(*this, level, internalFormat,
@ -1138,8 +1138,8 @@ void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat);
const PixelFormat format = imageFormatForInternalFormat(internalFormat);
const PixelType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic types */
#ifndef MAGNUM_TARGET_GLES
@ -1207,8 +1207,8 @@ void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat
#if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat);
const PixelFormat format = imageFormatForInternalFormat(internalFormat);
const PixelType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic type */
#ifndef MAGNUM_TARGET_GLES2
@ -1318,7 +1318,7 @@ void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei sampl
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::getImageImplementationDefault(const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
void AbstractTexture::getImageImplementationDefault(const GLint level, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) {
bindInternal();
glGetTexImage(_target, level, GLenum(format), GLenum(type), data);
}
@ -1328,7 +1328,7 @@ void AbstractTexture::getCompressedImageImplementationDefault(const GLint level,
glGetCompressedTexImage(_target, level, data);
}
void AbstractTexture::getImageImplementationDSA(const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
void AbstractTexture::getImageImplementationDSA(const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
glGetTextureImage(_id, level, GLenum(format), GLenum(type), dataSize, data);
}
@ -1336,7 +1336,7 @@ void AbstractTexture::getCompressedImageImplementationDSA(const GLint level, con
glGetCompressedTextureImage(_id, level, dataSize, data);
}
void AbstractTexture::getImageImplementationDSAEXT(const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
void AbstractTexture::getImageImplementationDSAEXT(const GLint level, const PixelFormat format, const PixelType type, const std::size_t, GLvoid* const data) {
_flags |= ObjectFlag::Created;
glGetTextureImageEXT(_id, _target, level, GLenum(format), GLenum(type), data);
}
@ -1346,7 +1346,7 @@ void AbstractTexture::getCompressedImageImplementationDSAEXT(const GLint level,
glGetCompressedTextureImageEXT(_id, _target, level, data);
}
void AbstractTexture::getImageImplementationRobustness(const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
void AbstractTexture::getImageImplementationRobustness(const GLint level, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
bindInternal();
glGetnTexImageARB(_target, level, GLenum(format), GLenum(type), dataSize, data);
}
@ -1358,67 +1358,67 @@ void AbstractTexture::getCompressedImageImplementationRobustness(const GLint lev
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data) {
bindInternal();
glTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
bindInternal();
glCompressedTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), data.size(), data);
}
void AbstractTexture::subImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
void AbstractTexture::subImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
glTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
glCompressedTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), data.size(), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data) {
_flags |= ObjectFlag::Created;
glTextureSubImage1DEXT(_id, _target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDSAEXT(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDSAEXT(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
_flags |= ObjectFlag::Created;
glCompressedTextureSubImage1DEXT(_id, _target, level, offset[0], size[0], GLenum(format), data.size(), data);
}
#endif
void AbstractTexture::subImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data) {
bindInternal();
glTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
bindInternal();
glCompressedTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), data.size(), data);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
glTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
glCompressedTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), data.size(), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data) {
_flags |= ObjectFlag::Created;
glTextureSubImage2DEXT(_id, _target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Corrade::Containers::ArrayView< const GLvoid > data) {
void AbstractTexture::compressedSubImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Corrade::Containers::ArrayView< const GLvoid > data) {
_flags |= ObjectFlag::Created;
glCompressedTextureSubImage2DEXT(_id, _target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), data.size(), data);
}
#endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void AbstractTexture::subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data) {
bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
@ -1435,7 +1435,7 @@ void AbstractTexture::subImageImplementationDefault(GLint level, const Vector3i&
#endif
}
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glCompressedTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), data.size(), data);
@ -1453,20 +1453,20 @@ void AbstractTexture::compressedSubImageImplementationDefault(const GLint level,
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
glTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), data.size(), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data) {
_flags |= ObjectFlag::Created;
glTextureSubImage3DEXT(_id, _target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::compressedSubImageImplementationDSAEXT(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void AbstractTexture::compressedSubImageImplementationDSAEXT(const GLint level, const Vector3i& offset, const Vector3i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
_flags |= ObjectFlag::Created;
glCompressedTextureSubImage3DEXT(_id, _target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), data.size(), data);
}
@ -1530,7 +1530,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
(this->*Context::current()->state().texture->getCompressedImageImplementation)(level, dataSize, data);
image.setData(CompressedColorFormat(format), size, std::move(data));
image.setData(CompressedPixelFormat(format), size, std::move(data));
}
template void MAGNUM_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedImage<1>&);
@ -1544,7 +1544,7 @@ template<UnsignedInt dimensions> void AbstractTexture::compressedImage(const GLi
GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
image.setData(CompressedColorFormat(format), size, {nullptr, std::size_t(dataSize)}, usage);
image.setData(CompressedPixelFormat(format), size, {nullptr, std::size_t(dataSize)}, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
(this->*Context::current()->state().texture->getCompressedImageImplementation)(level, dataSize, nullptr);
}

48
src/Magnum/AbstractTexture.h

@ -522,10 +522,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getImageImplementationDefault(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSA(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSAEXT(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationRobustness(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDefault(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSA(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSAEXT(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationRobustness(GLint level, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getCompressedImageImplementationDefault(GLint level, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getCompressedImageImplementationDSA(GLint level, std::size_t dataSize, GLvoid* data);
@ -534,33 +534,33 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#endif
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#endif
void MAGNUM_LOCAL invalidateImageImplementationNoOp(GLint level);
@ -574,8 +574,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
#endif
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2)
ColorFormat MAGNUM_LOCAL imageFormatForInternalFormat(TextureFormat internalFormat);
ColorType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat);
PixelFormat MAGNUM_LOCAL imageFormatForInternalFormat(TextureFormat internalFormat);
PixelType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat);
#endif
GLuint _id;

10
src/Magnum/BufferImage.cpp

@ -28,26 +28,26 @@
namespace Magnum {
#ifndef MAGNUM_TARGET_GLES2
template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage): _format{format}, _type{type}, _size{size}, _buffer{Buffer::TargetHint::PixelPack} {
template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage): _format{format}, _type{type}, _size{size}, _buffer{Buffer::TargetHint::PixelPack} {
_buffer.setData({data, dataSize(size)}, usage);
}
template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(ColorFormat format, ColorType type): _format{format}, _type{type}, _buffer{Buffer::TargetHint::PixelPack} {}
template<UnsignedInt dimensions> BufferImage<dimensions>::BufferImage(PixelFormat format, PixelType type): _format{format}, _type{type}, _buffer{Buffer::TargetHint::PixelPack} {}
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage) {
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage) {
_format = format;
_type = type;
_size = size;
_buffer.setData({data, dataSize(size)}, usage);
}
template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBufferImage(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage): _format{format}, _size{size}, _buffer{Buffer::TargetHint::PixelPack}, _dataSize{data.size()} {
template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBufferImage(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage): _format{format}, _size{size}, _buffer{Buffer::TargetHint::PixelPack}, _dataSize{data.size()} {
_buffer.setData(data, usage);
}
template<UnsignedInt dimensions> CompressedBufferImage<dimensions>::CompressedBufferImage(): _format{}, _buffer{Buffer::TargetHint::PixelPack}, _dataSize{} {}
template<UnsignedInt dimensions> void CompressedBufferImage<dimensions>::setData(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage) {
template<UnsignedInt dimensions> void CompressedBufferImage<dimensions>::setData(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage) {
_format = format;
_size = size;
_buffer.setData(data, usage);

22
src/Magnum/BufferImage.h

@ -67,7 +67,7 @@ template<UnsignedInt dimensions> class BufferImage {
* @todo Make it more flexible (usable with
* @extension{ARB,buffer_storage}, avoiding relocations...)
*/
explicit BufferImage(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage);
explicit BufferImage(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage);
/**
* @brief Constructor
@ -77,7 +77,7 @@ template<UnsignedInt dimensions> class BufferImage {
* Size is zero and buffer are empty, call @ref setData() to fill the
* image with data.
*/
/*implicit*/ BufferImage(ColorFormat format, ColorType type);
/*implicit*/ BufferImage(PixelFormat format, PixelType type);
/** @brief Copying is not allowed */
BufferImage(const BufferImage<dimensions>&) = delete;
@ -92,10 +92,10 @@ template<UnsignedInt dimensions> class BufferImage {
BufferImage<dimensions>& operator=(BufferImage<dimensions>&& other) noexcept;
/** @brief Format of pixel data */
ColorFormat format() const { return _format; }
PixelFormat format() const { return _format; }
/** @brief Data type of pixel data */
ColorType type() const { return _type; }
PixelType type() const { return _type; }
/** @brief Pixel size (in bytes) */
std::size_t pixelSize() const { return Implementation::imagePixelSize(_format, _type); }
@ -125,11 +125,11 @@ template<UnsignedInt dimensions> class BufferImage {
* @todo Make it more flexible (usable with
* @extension{ARB,buffer_storage}, avoiding relocations...)
*/
void setData(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage);
void setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const void* data, BufferUsage usage);
private:
ColorFormat _format;
ColorType _type;
PixelFormat _format;
PixelType _type;
Math::Vector<Dimensions, Int> _size;
Buffer _buffer;
};
@ -172,7 +172,7 @@ template<UnsignedInt dimensions> class CompressedBufferImage {
* @todo Make it more flexible (usable with
* @extension{ARB,buffer_storage}, avoiding relocations...)
*/
explicit CompressedBufferImage(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage);
explicit CompressedBufferImage(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage);
/**
* @brief Constructor
@ -195,7 +195,7 @@ template<UnsignedInt dimensions> class CompressedBufferImage {
CompressedBufferImage<dimensions>& operator=(CompressedBufferImage<dimensions>&& other) noexcept;
/** @brief Format of compressed data */
CompressedColorFormat format() const { return _format; }
CompressedPixelFormat format() const { return _format; }
/** @brief Image size */
VectorTypeFor<Dimensions, Int> size() const { return _size; }
@ -219,10 +219,10 @@ template<UnsignedInt dimensions> class CompressedBufferImage {
* @todo Make it more flexible (usable with
* @extension{ARB,buffer_storage}, avoiding relocations...)
*/
void setData(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage);
void setData(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data, BufferUsage usage);
private:
CompressedColorFormat _format;
CompressedPixelFormat _format;
Math::Vector<Dimensions, Int> _size;
Buffer _buffer;
std::size_t _dataSize;

5
src/Magnum/CMakeLists.txt

@ -34,7 +34,6 @@ set(Magnum_SRCS
AbstractShaderProgram.cpp
Attribute.cpp
Buffer.cpp
ColorFormat.cpp
CubeMapTexture.cpp
Context.cpp
DefaultFramebuffer.cpp
@ -43,6 +42,7 @@ set(Magnum_SRCS
Mesh.cpp
MeshView.cpp
OpenGL.cpp
PixelFormat.cpp
PixelStorage.cpp
Renderbuffer.cpp
Renderer.cpp
@ -86,7 +86,6 @@ set(Magnum_HEADERS
Array.h
Attribute.h
Buffer.h
ColorFormat.h
Context.h
CubeMapTexture.h
DefaultFramebuffer.h
@ -99,6 +98,7 @@ set(Magnum_HEADERS
Mesh.h
MeshView.h
OpenGL.h
PixelFormat.h
PixelStorage.h
Renderbuffer.h
RenderbufferFormat.h
@ -133,6 +133,7 @@ set(Magnum_PRIVATE_HEADERS
if(BUILD_DEPRECATED)
list(APPEND Magnum_HEADERS
Color.h
ColorFormat.h
ImageReference.h)
endif()

1188
src/Magnum/ColorFormat.h

File diff suppressed because it is too large Load Diff

28
src/Magnum/CubeMapTexture.cpp

@ -101,7 +101,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image)
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
glGetCompressedTextureImage(_id, level, dataSize, data);
image.setData(CompressedColorFormat(format), size, std::move(data));
image.setData(CompressedPixelFormat(format), size, std::move(data));
}
CompressedImage3D CubeMapTexture::compressedImage(const Int level, CompressedImage3D&& image) {
@ -119,7 +119,7 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
image.setData(CompressedColorFormat(format), size, {nullptr, std::size_t(dataSize)}, usage);
image.setData(CompressedPixelFormat(format), size, {nullptr, std::size_t(dataSize)}, usage);
glGetCompressedTextureImage(_id, level, dataSize, nullptr);
}
@ -168,7 +168,7 @@ void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int leve
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
(this->*Context::current()->state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, data);
image.setData(CompressedColorFormat(format), size, std::move(data));
image.setData(CompressedPixelFormat(format), size, std::move(data));
}
CompressedImage2D CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedImage2D&& image) {
@ -183,7 +183,7 @@ void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int leve
GLint format;
(this->*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format);
image.setData(CompressedColorFormat(format), size, {nullptr, std::size_t(dataSize)}, usage);
image.setData(CompressedPixelFormat(format), size, {nullptr, std::size_t(dataSize)}, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
(this->*Context::current()->state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr);
}
@ -296,7 +296,7 @@ Vector2i CubeMapTexture::getImageSizeImplementationDSAEXT(const Int level) {
#endif
#ifndef MAGNUM_TARGET_GLES
void CubeMapTexture::getImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i&, const ColorFormat format, const ColorType type, std::size_t, GLvoid* const data) {
void CubeMapTexture::getImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) {
bindInternal();
glGetTexImage(GLenum(coordinate), level, GLenum(format), GLenum(type), data);
}
@ -306,7 +306,7 @@ void CubeMapTexture::getCompressedImageImplementationDefault(const Coordinate co
glGetCompressedTexImage(GLenum(coordinate), level, data);
}
void CubeMapTexture::getImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
void CubeMapTexture::getImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& size, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
glGetTextureSubImage(_id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), dataSize, data);
}
@ -314,7 +314,7 @@ void CubeMapTexture::getCompressedImageImplementationDSA(const Coordinate coordi
glGetCompressedTextureSubImage(_id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, dataSize, data);
}
void CubeMapTexture::getImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i&, const ColorFormat format, const ColorType type, std::size_t, GLvoid* const data) {
void CubeMapTexture::getImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) {
_flags |= ObjectFlag::Created;
glGetTextureImageEXT(_id, GLenum(coordinate), level, GLenum(format), GLenum(type), data);
}
@ -324,7 +324,7 @@ void CubeMapTexture::getCompressedImageImplementationDSAEXT(const Coordinate coo
glGetCompressedTextureImageEXT(_id, GLenum(coordinate), level, data);
}
void CubeMapTexture::getImageImplementationRobustness(const Coordinate coordinate, const GLint level, const Vector2i&, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
void CubeMapTexture::getImageImplementationRobustness(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
bindInternal();
glGetnTexImageARB(GLenum(coordinate), level, GLenum(format), GLenum(type), dataSize, data);
}
@ -335,31 +335,31 @@ void CubeMapTexture::getCompressedImageImplementationRobustness(const Coordinate
}
#endif
void CubeMapTexture::subImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
void CubeMapTexture::subImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
bindInternal();
glTexSubImage2D(GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
void CubeMapTexture::compressedSubImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void CubeMapTexture::compressedSubImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
bindInternal();
glCompressedTexSubImage2D(GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), data.size(), data);
}
#ifndef MAGNUM_TARGET_GLES
void CubeMapTexture::subImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
void CubeMapTexture::subImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
glTextureSubImage3D(_id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), data);
}
void CubeMapTexture::compressedSubImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void CubeMapTexture::compressedSubImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), data.size(), data);
}
void CubeMapTexture::subImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
void CubeMapTexture::subImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) {
_flags |= ObjectFlag::Created;
glTextureSubImage2DEXT(_id, GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
void CubeMapTexture::compressedSubImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedColorFormat format, const Containers::ArrayView<const GLvoid> data) {
void CubeMapTexture::compressedSubImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const Containers::ArrayView<const GLvoid> data) {
_flags |= ObjectFlag::Created;
glTextureSubImage2DEXT(_id, GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), data.size(), data);
}

34
src/Magnum/CubeMapTexture.h

@ -57,7 +57,7 @@ See @ref Texture documentation for introduction.
Common usage is to fully configure all texture parameters and then set the
data from e.g. set of Image objects:
@code
Image2D positiveX(ColorFormat::RGBA, ColorType::UnsignedByte, {256, 256}, data);
Image2D positiveX(PixelFormat::RGBA, PixelType::UnsignedByte, {256, 256}, data);
// ...
CubeMapTexture texture;
@ -454,7 +454,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image3D image(Int level, Image3D&& image);
@ -473,7 +473,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage3D image(Int level, BufferImage3D&& image, BufferUsage usage);
@ -556,7 +556,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image2D image(Coordinate coordinate, Int level, Image2D&& image);
@ -574,7 +574,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage2D image(Coordinate coordinate, Int level, BufferImage2D&& image, BufferUsage usage);
@ -653,7 +653,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image3D image = texture.subImage(0, range, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image3D image = texture.subImage(0, range, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image3D subImage(Int level, const Range3Di& range, Image3D&& image);
@ -675,7 +675,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage3D image = texture.subImage(0, range, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage3D image = texture.subImage(0, range, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage3D subImage(Int level, const Range3Di& range, BufferImage3D&& image, BufferUsage usage);
@ -939,10 +939,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationRobustness(Coordinate coordinate, GLint level, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationRobustness(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getCompressedImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getCompressedImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data);
@ -950,16 +950,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
void MAGNUM_LOCAL getCompressedImageImplementationRobustness(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data);
#endif
void MAGNUM_LOCAL subImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data);
#endif
void MAGNUM_LOCAL compressedSubImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL compressedSubImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedColorFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, Containers::ArrayView<const GLvoid> data);
#endif
};

10
src/Magnum/CubeMapTextureArray.h

@ -58,7 +58,7 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
.setStorage(Math::log2(64)+1, TextureFormat::RGBA8, {64, 64, 24});
for(std::size_t i = 0; i != 4; i += 6) {
Image3D imagePositiveX(ColorFormat::RGBA, ColorType::UnsignedByte, {64, 64, 1}, data);
Image3D imagePositiveX(PixelFormat::RGBA, PixelType::UnsignedByte, {64, 64, 1}, data);
// ...
texture.setSubImage(0, Vector3i::zAxis(i+0), imagePositiveX);
texture.setSubImage(0, Vector3i::zAxis(i+1), imageNegativeX);
@ -387,7 +387,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image3D image(Int level, Image3D&& image);
@ -408,7 +408,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage3D image(Int level, BufferImage3D&& image, BufferUsage usage);
@ -472,7 +472,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image3D image = texture.subImage(0, range, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image3D image = texture.subImage(0, range, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image3D subImage(Int level, const Range3Di& range, Image3D&& image);
@ -494,7 +494,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage3D image = texture.subImage(0, range, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage3D image = texture.subImage(0, range, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage3D subImage(Int level, const Range3Di& range, BufferImage3D&& image, BufferUsage usage);

4
src/Magnum/Image.cpp

@ -27,7 +27,7 @@
namespace Magnum {
template<UnsignedInt dimensions> void Image<dimensions>::setData(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, void* data) {
template<UnsignedInt dimensions> void Image<dimensions>::setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data) {
delete[] _data;
_format = format;
_type = type;
@ -35,7 +35,7 @@ template<UnsignedInt dimensions> void Image<dimensions>::setData(ColorFormat for
_data = reinterpret_cast<char*>(data);
}
template<UnsignedInt dimensions> void CompressedImage<dimensions>::setData(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) {
template<UnsignedInt dimensions> void CompressedImage<dimensions>::setData(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data) {
_format = format;
_size = size;
_data = std::move(data);

22
src/Magnum/Image.h

@ -58,7 +58,7 @@ template<UnsignedInt dimensions> class Image {
* Note that the image data are not copied on construction, but they
* are deleted on class destruction.
*/
explicit Image(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, void* data): _format{format}, _type{type}, _size{size}, _data{reinterpret_cast<char*>(data)} {}
explicit Image(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data): _format{format}, _type{type}, _size{size}, _data{reinterpret_cast<char*>(data)} {}
/**
* @brief Constructor
@ -68,7 +68,7 @@ template<UnsignedInt dimensions> class Image {
* Dimensions are set to zero and data pointer to `nullptr`, call
* @ref setData() to fill the image with data.
*/
/*implicit*/ Image(ColorFormat format, ColorType type): _format{format}, _type{type}, _data{} {}
/*implicit*/ Image(PixelFormat format, PixelType type): _format{format}, _type{type}, _data{} {}
/** @brief Copying is not allowed */
Image(const Image<dimensions>&) = delete;
@ -99,10 +99,10 @@ template<UnsignedInt dimensions> class Image {
#endif
/** @brief Format of pixel data */
ColorFormat format() const { return _format; }
PixelFormat format() const { return _format; }
/** @brief Data type of pixel data */
ColorType type() const { return _type; }
PixelType type() const { return _type; }
/** @brief Pixel size (in bytes) */
std::size_t pixelSize() const { return Implementation::imagePixelSize(_format, _type); }
@ -146,7 +146,7 @@ template<UnsignedInt dimensions> class Image {
* data are not copied, but they are deleted on destruction.
* @see @ref release()
*/
void setData(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, void* data);
void setData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data);
/**
* @brief Release data storage
@ -158,8 +158,8 @@ template<UnsignedInt dimensions> class Image {
char* release();
private:
ColorFormat _format;
ColorType _type;
PixelFormat _format;
PixelType _type;
Math::Vector<Dimensions, Int> _size;
char* _data;
};
@ -194,7 +194,7 @@ template<UnsignedInt dimensions> class CompressedImage {
* @param size Image size
* @param data Image data
*/
explicit CompressedImage(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data): _format{format}, _size{size}, _data{std::move(data)} {}
explicit CompressedImage(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data): _format{format}, _size{size}, _data{std::move(data)} {}
/**
* @brief Constructor
@ -230,7 +230,7 @@ template<UnsignedInt dimensions> class CompressedImage {
#endif
/** @brief Format of compressed data */
CompressedColorFormat format() const { return _format; }
CompressedPixelFormat format() const { return _format; }
/** @brief Image size */
VectorTypeFor<dimensions, Int> size() const { return _size; }
@ -265,7 +265,7 @@ template<UnsignedInt dimensions> class CompressedImage {
* data are not copied, but they are deleted on destruction.
* @see @ref release()
*/
void setData(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data);
void setData(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data);
/**
* @brief Release data storage
@ -277,7 +277,7 @@ template<UnsignedInt dimensions> class CompressedImage {
Containers::Array<char> release();
private:
CompressedColorFormat _format;
CompressedPixelFormat _format;
Math::Vector<Dimensions, Int> _size;
Containers::Array<char> _data;
};

20
src/Magnum/ImageView.h

@ -66,7 +66,7 @@ template<UnsignedInt dimensions> class ImageView {
* @param size Image size
* @param data Image data
*/
constexpr explicit ImageView(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, const void* data): _format{format}, _type{type}, _size{size}, _data{reinterpret_cast<const char*>(data)} {}
constexpr explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, const void* data): _format{format}, _type{type}, _size{size}, _data{reinterpret_cast<const char*>(data)} {}
/**
* @brief Constructor
@ -77,13 +77,13 @@ template<UnsignedInt dimensions> class ImageView {
* Data pointer is set to `nullptr`, call @ref setData() to fill the
* image with data.
*/
constexpr explicit ImageView(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size): _format{format}, _type{type}, _size{size}, _data{nullptr} {}
constexpr explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size): _format{format}, _type{type}, _size{size}, _data{nullptr} {}
/** @brief Format of pixel data */
ColorFormat format() const { return _format; }
PixelFormat format() const { return _format; }
/** @brief Data type of pixel data */
ColorType type() const { return _type; }
PixelType type() const { return _type; }
/** @brief Pixel size (in bytes) */
std::size_t pixelSize() const { return Implementation::imagePixelSize(_format, _type); }
@ -117,8 +117,8 @@ template<UnsignedInt dimensions> class ImageView {
}
private:
ColorFormat _format;
ColorType _type;
PixelFormat _format;
PixelType _type;
Math::Vector<Dimensions, Int> _size;
const char* _data;
};
@ -154,7 +154,7 @@ template<UnsignedInt dimensions> class CompressedImageView {
* @param size Image size
* @param data Image data
*/
constexpr explicit CompressedImageView(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data): _format{format}, _size{size}, _data{reinterpret_cast<const char*>(data.data()), data.size()} {}
constexpr explicit CompressedImageView(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data): _format{format}, _size{size}, _data{reinterpret_cast<const char*>(data.data()), data.size()} {}
/**
* @brief Constructor
@ -164,10 +164,10 @@ template<UnsignedInt dimensions> class CompressedImageView {
* Data pointer is set to `nullptr`, call @ref setData() to fill the
* image with data.
*/
constexpr explicit CompressedImageView(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size): _format{format}, _size{size} {}
constexpr explicit CompressedImageView(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size): _format{format}, _size{size} {}
/** @brief Format of compressed data */
CompressedColorFormat format() const { return _format; }
CompressedPixelFormat format() const { return _format; }
/** @brief Image size */
constexpr VectorTypeFor<dimensions, Int> size() const { return _size; }
@ -193,7 +193,7 @@ template<UnsignedInt dimensions> class CompressedImageView {
}
private:
CompressedColorFormat _format;
CompressedPixelFormat _format;
Math::Vector<Dimensions, Int> _size;
Containers::ArrayView<const char> _data;
};

2
src/Magnum/Implementation/FramebufferState.h

@ -81,7 +81,7 @@ struct FramebufferState {
void(Renderbuffer::*renderbufferStorageMultisampleImplementation)(GLsizei, RenderbufferFormat, const Vector2i&);
#endif
void(*readImplementation)(const Range2Di&, ColorFormat, ColorType, std::size_t, GLvoid*);
void(*readImplementation)(const Range2Di&, PixelFormat, PixelType, std::size_t, GLvoid*);
GLuint readBinding, drawBinding, renderbufferBinding;
GLint maxDrawBuffers, maxColorAttachments, maxRenderbufferSize;

20
src/Magnum/Implementation/TextureState.h

@ -69,18 +69,18 @@ struct TextureState {
void(AbstractTexture::*storage3DMultisampleImplementation)(GLsizei, TextureFormat, const Vector3i&, GLboolean);
#endif
#ifndef MAGNUM_TARGET_GLES
void(AbstractTexture::*getImageImplementation)(GLint, ColorFormat, ColorType, std::size_t, GLvoid*);
void(AbstractTexture::*getImageImplementation)(GLint, PixelFormat, PixelType, std::size_t, GLvoid*);
void(AbstractTexture::*getCompressedImageImplementation)(GLint, std::size_t, GLvoid*);
#endif
#ifndef MAGNUM_TARGET_GLES
void(AbstractTexture::*subImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, ColorFormat, ColorType, const GLvoid*);
void(AbstractTexture::*compressedSubImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, CompressedColorFormat, Containers::ArrayView<const GLvoid>);
void(AbstractTexture::*subImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, PixelFormat, PixelType, const GLvoid*);
void(AbstractTexture::*compressedSubImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, CompressedPixelFormat, Containers::ArrayView<const GLvoid>);
#endif
void(AbstractTexture::*subImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, ColorFormat, ColorType, const GLvoid*);
void(AbstractTexture::*compressedSubImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, CompressedColorFormat, Containers::ArrayView<const GLvoid>);
void(AbstractTexture::*subImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*);
void(AbstractTexture::*compressedSubImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, Containers::ArrayView<const GLvoid>);
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
void(AbstractTexture::*subImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, ColorFormat, ColorType, const GLvoid*);
void(AbstractTexture::*compressedSubImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, CompressedColorFormat, Containers::ArrayView<const GLvoid>);
void(AbstractTexture::*subImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, PixelFormat, PixelType, const GLvoid*);
void(AbstractTexture::*compressedSubImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, CompressedPixelFormat, Containers::ArrayView<const GLvoid>);
#endif
void(AbstractTexture::*invalidateImageImplementation)(GLint);
void(AbstractTexture::*invalidateSubImageImplementation)(GLint, const Vector3i&, const Vector3i&);
@ -94,11 +94,11 @@ struct TextureState {
Vector2i(CubeMapTexture::*getCubeImageSizeImplementation)(Int);
#endif
#ifndef MAGNUM_TARGET_GLES
void(CubeMapTexture::*getCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, ColorFormat, ColorType, std::size_t, GLvoid*);
void(CubeMapTexture::*getCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*);
void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, std::size_t, GLvoid*);
#endif
void(CubeMapTexture::*cubeSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, ColorFormat, ColorType, const GLvoid*);
void(CubeMapTexture::*cubeCompressedSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, CompressedColorFormat, Containers::ArrayView<const GLvoid>);
void(CubeMapTexture::*cubeSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*);
void(CubeMapTexture::*cubeCompressedSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, Containers::ArrayView<const GLvoid>);
GLint maxSize,
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))

13
src/Magnum/Magnum.h

@ -471,10 +471,6 @@ template<class T> using BasicColor3 CORRADE_DEPRECATED_ALIAS("use Math::Color3 i
template<class T> using BasicColor4 CORRADE_DEPRECATED_ALIAS("use Math::Color4 instead") = Math::Color4<T>;
#endif
enum class ColorFormat: GLenum;
enum class ColorType: GLenum;
enum class CompressedColorFormat: GLenum;
class Context;
class CubeMapTexture;
@ -528,6 +524,15 @@ typedef MultisampleTexture<2> MultisampleTexture2D;
typedef MultisampleTexture<3> MultisampleTexture2DArray;
#endif
enum class PixelFormat: GLenum;
enum class PixelType: GLenum;
enum class CompressedPixelFormat: GLenum;
#ifdef MAGNUM_BUILD_DEPRECATED
typedef CORRADE_DEPRECATED("use PixelFormat instead") PixelFormat ColorFormat;
typedef CORRADE_DEPRECATED("use PixelType instead") PixelType ColorType;
typedef CORRADE_DEPRECATED("use CompressedPixelFormat instead") CompressedPixelFormat CompressedColorFormat;
#endif
/* ObjectFlag, ObjectFlags are used only in conjunction with *::wrap() function */
class PrimitiveQuery;

20
src/Magnum/ColorFormat.cpp → src/Magnum/PixelFormat.cpp

@ -23,16 +23,16 @@
DEALINGS IN THE SOFTWARE.
*/
#include "ColorFormat.h"
#include "PixelFormat.h"
#include <Corrade/Utility/Debug.h>
namespace Magnum {
#ifndef DOXYGEN_GENERATING_OUTPUT
Debug operator<<(Debug debug, const ColorFormat value) {
Debug operator<<(Debug debug, const PixelFormat value) {
switch(value) {
#define _c(value) case ColorFormat::value: return debug << "ColorFormat::" #value;
#define _c(value) case PixelFormat::value: return debug << "PixelFormat::" #value;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
_c(Red)
#endif
@ -79,12 +79,12 @@ Debug operator<<(Debug debug, const ColorFormat value) {
#undef _c
}
return debug << "ColorFormat::(invalid)";
return debug << "PixelFormat::(invalid)";
}
Debug operator<<(Debug debug, const ColorType value) {
Debug operator<<(Debug debug, const PixelType value) {
switch(value) {
#define _c(value) case ColorType::value: return debug << "ColorType::" #value;
#define _c(value) case PixelType::value: return debug << "PixelType::" #value;
_c(UnsignedByte)
#ifndef MAGNUM_TARGET_GLES2
_c(Byte)
@ -134,12 +134,12 @@ Debug operator<<(Debug debug, const ColorType value) {
#undef _c
}
return debug << "ColorType::(invalid)";
return debug << "PixelType::(invalid)";
}
Debug operator<<(Debug debug, const CompressedColorFormat value) {
Debug operator<<(Debug debug, const CompressedPixelFormat value) {
switch(value) {
#define _c(value) case CompressedColorFormat::value: return debug << "CompressedColorFormat::" #value;
#define _c(value) case CompressedPixelFormat::value: return debug << "CompressedPixelFormat::" #value;
#ifndef MAGNUM_TARGET_GLES
_c(Red)
_c(RG)
@ -203,7 +203,7 @@ Debug operator<<(Debug debug, const CompressedColorFormat value) {
#undef _c
}
return debug << "CompressedColorFormat::(invalid)";
return debug << "CompressedPixelFormat::(invalid)";
}
#endif

1206
src/Magnum/PixelFormat.h

File diff suppressed because it is too large Load Diff

104
src/Magnum/PixelStorage.cpp

@ -27,131 +27,131 @@
#include <Corrade/Utility/Assert.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Math/Vector.h"
namespace Magnum { namespace Implementation {
std::size_t imagePixelSize(ColorFormat format, ColorType type) {
std::size_t imagePixelSize(PixelFormat format, PixelType type) {
std::size_t size = 0;
switch(type) {
case ColorType::UnsignedByte:
case PixelType::UnsignedByte:
#ifndef MAGNUM_TARGET_GLES2
case ColorType::Byte:
case PixelType::Byte:
#endif
size = 1; break;
case ColorType::UnsignedShort:
case PixelType::UnsignedShort:
#ifndef MAGNUM_TARGET_GLES2
case ColorType::Short:
case PixelType::Short:
#endif
case ColorType::HalfFloat:
case PixelType::HalfFloat:
size = 2; break;
case ColorType::UnsignedInt:
case PixelType::UnsignedInt:
#ifndef MAGNUM_TARGET_GLES2
case ColorType::Int:
case PixelType::Int:
#endif
case ColorType::Float:
case PixelType::Float:
size = 4; break;
#ifndef MAGNUM_TARGET_GLES
case ColorType::UnsignedByte332:
case ColorType::UnsignedByte233Rev:
case PixelType::UnsignedByte332:
case PixelType::UnsignedByte233Rev:
return 1;
#endif
case ColorType::UnsignedShort565:
case PixelType::UnsignedShort565:
#ifndef MAGNUM_TARGET_GLES
case ColorType::UnsignedShort565Rev:
case PixelType::UnsignedShort565Rev:
#endif
case ColorType::UnsignedShort4444:
case PixelType::UnsignedShort4444:
#ifndef MAGNUM_TARGET_WEBGL
case ColorType::UnsignedShort4444Rev:
case PixelType::UnsignedShort4444Rev:
#endif
case ColorType::UnsignedShort5551:
case PixelType::UnsignedShort5551:
#ifndef MAGNUM_TARGET_WEBGL
case ColorType::UnsignedShort1555Rev:
case PixelType::UnsignedShort1555Rev:
#endif
return 2;
#ifndef MAGNUM_TARGET_GLES
case ColorType::UnsignedInt8888:
case ColorType::UnsignedInt8888Rev:
case ColorType::UnsignedInt1010102:
case PixelType::UnsignedInt8888:
case PixelType::UnsignedInt8888Rev:
case PixelType::UnsignedInt1010102:
#endif
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case ColorType::UnsignedInt2101010Rev:
case PixelType::UnsignedInt2101010Rev:
#endif
#ifndef MAGNUM_TARGET_GLES2
case ColorType::UnsignedInt10F11F11FRev:
case ColorType::UnsignedInt5999Rev:
case PixelType::UnsignedInt10F11F11FRev:
case PixelType::UnsignedInt5999Rev:
#endif
case ColorType::UnsignedInt248:
case PixelType::UnsignedInt248:
return 4;
#ifndef MAGNUM_TARGET_GLES2
case ColorType::Float32UnsignedInt248Rev:
case PixelType::Float32UnsignedInt248Rev:
return 8;
#endif
}
switch(format) {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case ColorFormat::Red:
case PixelFormat::Red:
#endif
#ifndef MAGNUM_TARGET_GLES2
case ColorFormat::RedInteger:
case PixelFormat::RedInteger:
#endif
#ifndef MAGNUM_TARGET_GLES
case ColorFormat::Green:
case ColorFormat::Blue:
case ColorFormat::GreenInteger:
case ColorFormat::BlueInteger:
case PixelFormat::Green:
case PixelFormat::Blue:
case PixelFormat::GreenInteger:
case PixelFormat::BlueInteger:
#endif
#ifdef MAGNUM_TARGET_GLES2
case ColorFormat::Luminance:
case PixelFormat::Luminance:
#endif
case ColorFormat::DepthComponent:
case PixelFormat::DepthComponent:
#ifndef MAGNUM_TARGET_WEBGL
case ColorFormat::StencilIndex:
case PixelFormat::StencilIndex:
#endif
return 1*size;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case ColorFormat::RG:
case PixelFormat::RG:
#endif
#ifndef MAGNUM_TARGET_GLES2
case ColorFormat::RGInteger:
case PixelFormat::RGInteger:
#endif
#ifdef MAGNUM_TARGET_GLES2
case ColorFormat::LuminanceAlpha:
case PixelFormat::LuminanceAlpha:
#endif
return 2*size;
case ColorFormat::RGB:
case PixelFormat::RGB:
#ifndef MAGNUM_TARGET_GLES2
case ColorFormat::RGBInteger:
case PixelFormat::RGBInteger:
#endif
#ifndef MAGNUM_TARGET_GLES
case ColorFormat::BGR:
case ColorFormat::BGRInteger:
case PixelFormat::BGR:
case PixelFormat::BGRInteger:
#endif
return 3*size;
case ColorFormat::RGBA:
case PixelFormat::RGBA:
#ifndef MAGNUM_TARGET_GLES2
case ColorFormat::RGBAInteger:
case PixelFormat::RGBAInteger:
#endif
#ifndef MAGNUM_TARGET_WEBGL
case ColorFormat::BGRA:
case PixelFormat::BGRA:
#endif
#ifndef MAGNUM_TARGET_GLES
case ColorFormat::BGRAInteger:
case PixelFormat::BGRAInteger:
#endif
return 4*size;
/* Handled above */
case ColorFormat::DepthStencil:
CORRADE_ASSERT(false, "AbstractImage::pixelSize(): invalid ColorType specified for depth/stencil ColorFormat", 0);
case PixelFormat::DepthStencil:
CORRADE_ASSERT(false, "AbstractImage::pixelSize(): invalid PixelType specified for depth/stencil PixelFormat", 0);
}
CORRADE_ASSERT_UNREACHABLE();
}
template<UnsignedInt dimensions> std::size_t imageDataSize(const ColorFormat format, const ColorType type, Math::Vector<dimensions, Int> size) {
template<UnsignedInt dimensions> std::size_t imageDataSize(const PixelFormat format, const PixelType type, Math::Vector<dimensions, Int> size) {
/** @todo Code this properly when all @fn_gl{PixelStore} parameters are implemented */
/* Row size, rounded to multiple of 4 bytes */
const std::size_t rowSize = ((size[0]*imagePixelSize(format, type) + 3)/4)*4;
@ -161,8 +161,8 @@ template<UnsignedInt dimensions> std::size_t imageDataSize(const ColorFormat for
return rowSize*size.product();
}
template MAGNUM_EXPORT std::size_t imageDataSize<1>(ColorFormat, ColorType, Math::Vector<1, Int>);
template MAGNUM_EXPORT std::size_t imageDataSize<2>(ColorFormat, ColorType, Math::Vector<2, Int>);
template MAGNUM_EXPORT std::size_t imageDataSize<3>(ColorFormat, ColorType, Math::Vector<3, Int>);
template MAGNUM_EXPORT std::size_t imageDataSize<1>(PixelFormat, PixelType, Math::Vector<1, Int>);
template MAGNUM_EXPORT std::size_t imageDataSize<2>(PixelFormat, PixelType, Math::Vector<2, Int>);
template MAGNUM_EXPORT std::size_t imageDataSize<3>(PixelFormat, PixelType, Math::Vector<3, Int>);
}}

4
src/Magnum/PixelStorage.h

@ -37,9 +37,9 @@
namespace Magnum {
namespace Implementation {
std::size_t MAGNUM_EXPORT imagePixelSize(ColorFormat format, ColorType type);
std::size_t MAGNUM_EXPORT imagePixelSize(PixelFormat format, PixelType type);
template<UnsignedInt dimensions> std::size_t imageDataSize(ColorFormat format, ColorType type, Math::Vector<dimensions, Int> size);
template<UnsignedInt dimensions> std::size_t imageDataSize(PixelFormat format, PixelType type, Math::Vector<dimensions, Int> size);
}
}

10
src/Magnum/RectangleTexture.h

@ -48,7 +48,7 @@ See also @ref AbstractTexture documentation for more information.
Common usage is to fully configure all texture parameters and then set the
data from e.g. @ref Image2D. Example configuration:
@code
Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {526, 137}, data);
Image2D image(PixelFormat::RGBA, PixelType::UnsignedByte, {526, 137}, data);
RectangleTexture texture;
texture.setMagnificationFilter(Sampler::Filter::Linear)
@ -290,7 +290,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = texture.image({ColorFormat::RGBA, ColorType::UnsignedByte});
* Image2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image2D image(Image2D&& image);
@ -309,7 +309,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = texture.image({ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage2D image(BufferImage2D&& image, BufferUsage usage);
@ -367,7 +367,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = texture.subImage(range, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image2D image = texture.subImage(range, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image2D subImage(const Range2Di& range, Image2D&& image);
@ -387,7 +387,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = texture.subImage(range, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage2D image = texture.subImage(range, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage2D subImage(const Range2Di& range, BufferImage2D&& image, BufferUsage usage);

46
src/Magnum/Test/BufferImageGLTest.cpp

@ -26,7 +26,7 @@
#include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/BufferImage.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Test/AbstractOpenGLTester.h"
namespace Magnum { namespace Test {
@ -59,7 +59,7 @@ BufferImageGLTest::BufferImageGLTest() {
void BufferImageGLTest::construct() {
const char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0, 'c', 0, 0, 0 };
BufferImage2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data, BufferUsage::StaticDraw);
BufferImage2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data, BufferUsage::StaticDraw);
#ifndef MAGNUM_TARGET_GLES
const auto imageData = a.buffer().data();
@ -67,8 +67,8 @@ void BufferImageGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(a.format(), ColorFormat::Red);
CORRADE_COMPARE(a.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(a.format(), PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
/** @todo How to verify the contents in ES? */
@ -80,7 +80,7 @@ void BufferImageGLTest::construct() {
void BufferImageGLTest::constructCompressed() {
const char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0 };
CompressedBufferImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw};
CompressedBufferImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw};
#ifndef MAGNUM_TARGET_GLES
const auto imageData = a.buffer().data();
@ -88,7 +88,7 @@ void BufferImageGLTest::constructCompressed() {
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(a.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.size(), Vector2i(4, 4));
CORRADE_COMPARE(a.dataSize(), 8);
@ -111,7 +111,7 @@ void BufferImageGLTest::constructCopyCompressed() {
void BufferImageGLTest::constructMove() {
const char data[4] = { 'a', 'b', 'c', 'd' };
BufferImage2D a(ColorFormat::Red, ColorType::UnsignedByte, {4, 1}, data, BufferUsage::StaticDraw);
BufferImage2D a(PixelFormat::Red, PixelType::UnsignedByte, {4, 1}, data, BufferUsage::StaticDraw);
const Int id = a.buffer().id();
MAGNUM_VERIFY_NO_ERROR();
@ -122,13 +122,13 @@ void BufferImageGLTest::constructMove() {
CORRADE_COMPARE(a.buffer().id(), 0);
CORRADE_COMPARE(a.size(), Vector2i());
CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.format(), PixelFormat::Red);
CORRADE_COMPARE(b.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(4, 1));
CORRADE_COMPARE(b.buffer().id(), id);
const unsigned short data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 };
BufferImage2D c(ColorFormat::RGBA, ColorType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw);
BufferImage2D c(PixelFormat::RGBA, PixelType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw);
const Int cId = c.buffer().id();
c = std::move(b);
@ -138,15 +138,15 @@ void BufferImageGLTest::constructMove() {
CORRADE_COMPARE(b.buffer().id(), cId);
CORRADE_COMPARE(b.size(), Vector2i(1, 2));
CORRADE_COMPARE(c.format(), ColorFormat::Red);
CORRADE_COMPARE(c.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(c.format(), PixelFormat::Red);
CORRADE_COMPARE(c.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(c.size(), Vector2i(4, 1));
CORRADE_COMPARE(c.buffer().id(), id);
}
void BufferImageGLTest::constructMoveCompressed() {
const char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0 };
CompressedBufferImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw};
CompressedBufferImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw};
const Int id = a.buffer().id();
MAGNUM_VERIFY_NO_ERROR();
@ -158,13 +158,13 @@ void BufferImageGLTest::constructMoveCompressed() {
CORRADE_COMPARE(a.size(), Vector2i());
CORRADE_COMPARE(a.dataSize(), 0);
CORRADE_COMPARE(b.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.size(), Vector2i(4, 4));
CORRADE_COMPARE(b.dataSize(), 8);
CORRADE_COMPARE(b.buffer().id(), id);
const unsigned char data2[] = { 'a', 0, 0, 0, 'b', 0, 0, 0, 'c', 0, 0, 0, 'd', 0, 0, 0 };
CompressedBufferImage2D c{CompressedColorFormat::RGBAS3tcDxt1, {8, 4}, data2, BufferUsage::StaticDraw};
CompressedBufferImage2D c{CompressedPixelFormat::RGBAS3tcDxt1, {8, 4}, data2, BufferUsage::StaticDraw};
const Int cId = c.buffer().id();
c = std::move(b);
@ -175,7 +175,7 @@ void BufferImageGLTest::constructMoveCompressed() {
CORRADE_COMPARE(b.size(), Vector2i(8, 4));
CORRADE_COMPARE(b.dataSize(), 16);
CORRADE_COMPARE(c.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(c.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(c.size(), Vector2i(4, 4));
CORRADE_COMPARE(c.dataSize(), 8);
CORRADE_COMPARE(c.buffer().id(), id);
@ -183,10 +183,10 @@ void BufferImageGLTest::constructMoveCompressed() {
void BufferImageGLTest::setData() {
const char data[4] = { 'a', 'b', 'c', 'd' };
BufferImage2D a(ColorFormat::Red, ColorType::UnsignedByte, {4, 1}, data, BufferUsage::StaticDraw);
BufferImage2D a(PixelFormat::Red, PixelType::UnsignedByte, {4, 1}, data, BufferUsage::StaticDraw);
const UnsignedShort data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 };
a.setData(ColorFormat::RGBA, ColorType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw);
a.setData(PixelFormat::RGBA, PixelType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw);
#ifndef MAGNUM_TARGET_GLES
const auto imageData = a.buffer().data<UnsignedShort>();
@ -194,8 +194,8 @@ void BufferImageGLTest::setData() {
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(a.format(), ColorFormat::RGBA);
CORRADE_COMPARE(a.type(), ColorType::UnsignedShort);
CORRADE_COMPARE(a.format(), PixelFormat::RGBA);
CORRADE_COMPARE(a.type(), PixelType::UnsignedShort);
CORRADE_COMPARE(a.size(), Vector2i(1, 2));
/** @todo How to verify the contents in ES? */
@ -207,10 +207,10 @@ void BufferImageGLTest::setData() {
void BufferImageGLTest::setDataCompressed() {
const char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0 };
CompressedBufferImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw};
CompressedBufferImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw};
const char data2[] = { 'a', 0, 0, 0, 'b', 0, 0, 0, 'c', 0, 0, 0, 'd', 0, 0, 0 };
a.setData(CompressedColorFormat::RGBAS3tcDxt3, {8, 4}, data2, BufferUsage::StaticDraw);
a.setData(CompressedPixelFormat::RGBAS3tcDxt3, {8, 4}, data2, BufferUsage::StaticDraw);
#ifndef MAGNUM_TARGET_GLES
const auto imageData = a.buffer().data();
@ -218,7 +218,7 @@ void BufferImageGLTest::setDataCompressed() {
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(a.format(), CompressedColorFormat::RGBAS3tcDxt3);
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt3);
CORRADE_COMPARE(a.size(), Vector2i(8, 4));
CORRADE_COMPARE(a.dataSize(), 16);

44
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -26,9 +26,9 @@
#include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/BufferImage.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/CubeMapTextureArray.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h"
@ -388,13 +388,13 @@ void CubeMapTextureArrayGLTest::image() {
CubeMapTextureArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, Data));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, Data));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -417,7 +417,7 @@ void CubeMapTextureArrayGLTest::compressedImage() {
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{4, 4, 6}, CompressedData});
MAGNUM_VERIFY_NO_ERROR();
@ -445,13 +445,13 @@ void CubeMapTextureArrayGLTest::imageBuffer() {
CubeMapTextureArray texture;
texture.setImage(0, TextureFormat::RGBA8,
BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, Data, BufferUsage::StaticDraw));
BufferImage3D(PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -473,7 +473,7 @@ void CubeMapTextureArrayGLTest::compressedImageBuffer() {
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedBufferImage3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedBufferImage3D{CompressedPixelFormat::RGBAS3tcDxt3,
{4, 4, 6}, CompressedData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -627,15 +627,15 @@ void CubeMapTextureArrayGLTest::subImage() {
CubeMapTextureArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 6}, Zero));
texture.setSubImage(0, Vector3i(1),
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 4}, SubData));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -658,10 +658,10 @@ void CubeMapTextureArrayGLTest::compressedSubImage() {
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{12, 12, 6}, CompressedZero});
texture.setCompressedSubImage(0, {4, 4, 1},
CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData});
CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData});
MAGNUM_VERIFY_NO_ERROR();
@ -688,15 +688,15 @@ void CubeMapTextureArrayGLTest::subImageBuffer() {
CubeMapTextureArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, Zero));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 6}, Zero));
texture.setSubImage(0, Vector3i(1),
BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 4}, SubData, BufferUsage::StaticDraw));
BufferImage3D(PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 4}, SubData, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -718,10 +718,10 @@ void CubeMapTextureArrayGLTest::compressedSubImageBuffer() {
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
CubeMapTextureArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{12, 12, 6}, CompressedZero});
texture.setCompressedSubImage(0, {4, 4, 1},
CompressedBufferImage3D(CompressedColorFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData, BufferUsage::StaticDraw));
CompressedBufferImage3D(CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
@ -746,11 +746,11 @@ void CubeMapTextureArrayGLTest::subImageQuery() {
CubeMapTextureArray texture;
texture.setStorage(1, TextureFormat::RGBA8, {4, 4, 6})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, SubDataComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 6}, SubDataComplete});
MAGNUM_VERIFY_NO_ERROR();
Image3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, {2, 2, 4}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, {2, 2, 4}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -768,11 +768,11 @@ void CubeMapTextureArrayGLTest::subImageQueryBuffer() {
CubeMapTextureArray texture;
texture.setStorage(1, TextureFormat::RGBA8, {4, 4, 6})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 6}, SubDataComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 6}, SubDataComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, {2, 2, 4}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, {2, 2, 4}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -795,7 +795,7 @@ void CubeMapTextureArrayGLTest::generateMipmap() {
CubeMapTextureArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, {32, 32, 24}));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, {32, 32, 24}));
CORRADE_COMPARE(texture.imageSize(0), Vector3i(32, 32, 24));
CORRADE_COMPARE(texture.imageSize(1), Vector3i(0));

66
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -29,9 +29,9 @@
#ifndef MAGNUM_TARGET_GLES2
#include "Magnum/BufferImage.h"
#endif
#include "Magnum/ColorFormat.h"
#include "Magnum/CubeMapTexture.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h"
@ -423,11 +423,11 @@ void CubeMapTextureGLTest::imageFull() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2, 2})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, DataFull});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, DataFull});
MAGNUM_VERIFY_NO_ERROR();
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -445,7 +445,7 @@ void CubeMapTextureGLTest::compressedImageFull() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull});
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull});
MAGNUM_VERIFY_NO_ERROR();
@ -465,11 +465,11 @@ void CubeMapTextureGLTest::imageFullBuffer() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2})
.setSubImage(0, {}, BufferImage3D{ColorFormat::RGBA, ColorType::UnsignedByte, {2, 2, 6}, DataFull, BufferUsage::StaticDraw});
.setSubImage(0, {}, BufferImage3D{PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6}, DataFull, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
MAGNUM_VERIFY_NO_ERROR();
@ -486,7 +486,7 @@ void CubeMapTextureGLTest::compressedImageFullBuffer() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
.setCompressedSubImage(0, {}, CompressedBufferImage3D{CompressedColorFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull, BufferUsage::StaticDraw});
.setCompressedSubImage(0, {}, CompressedBufferImage3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6}, CompressedDataFull, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -516,13 +516,13 @@ namespace {
void CubeMapTextureGLTest::image() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -544,7 +544,7 @@ void CubeMapTextureGLTest::compressedImage() {
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData});
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData});
MAGNUM_VERIFY_NO_ERROR();
@ -564,13 +564,13 @@ void CubeMapTextureGLTest::compressedImage() {
void CubeMapTextureGLTest::imageBuffer() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -591,7 +591,7 @@ void CubeMapTextureGLTest::compressedImageBuffer() {
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData, BufferUsage::StaticDraw});
CompressedBufferImage2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -649,15 +649,15 @@ namespace {
void CubeMapTextureGLTest::subImage() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1),
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -679,9 +679,9 @@ void CubeMapTextureGLTest::compressedSubImage() {
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
texture.setCompressedSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i{4},
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData});
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData});
MAGNUM_VERIFY_NO_ERROR();
@ -701,15 +701,15 @@ void CubeMapTextureGLTest::compressedSubImage() {
void CubeMapTextureGLTest::subImageBuffer() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1),
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -730,9 +730,9 @@ void CubeMapTextureGLTest::compressedSubImageBuffer() {
CubeMapTexture texture;
texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0,
CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
texture.setCompressedSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i{4},
CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData, BufferUsage::StaticDraw});
CompressedBufferImage2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -759,11 +759,11 @@ void CubeMapTextureGLTest::subImageQuery() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 1}, SubDataComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 1}, SubDataComplete});
MAGNUM_VERIFY_NO_ERROR();
Image3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -782,11 +782,11 @@ void CubeMapTextureGLTest::subImageQueryBuffer() {
CubeMapTexture texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, {4, 4, 1}, SubDataComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 1}, SubDataComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -799,17 +799,17 @@ void CubeMapTextureGLTest::subImageQueryBuffer() {
void CubeMapTextureGLTest::generateMipmap() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::PositiveY, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::PositiveZ, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::NegativeX, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::NegativeY, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::NegativeZ, 0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES

32
src/Magnum/Test/FormatTest.cpp

@ -26,46 +26,46 @@
#include <sstream>
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
namespace Magnum { namespace Test {
struct FormatTest: TestSuite::Tester {
explicit FormatTest();
void debugColorFormat();
void debugColorType();
void debugCompressedColorFormat();
void debugPixelFormat();
void debugPixelType();
void debugCompressedPixelFormat();
};
FormatTest::FormatTest() {
addTests({&FormatTest::debugColorFormat,
&FormatTest::debugColorType,
&FormatTest::debugCompressedColorFormat});
addTests({&FormatTest::debugPixelFormat,
&FormatTest::debugPixelType,
&FormatTest::debugCompressedPixelFormat});
}
void FormatTest::debugColorFormat() {
void FormatTest::debugPixelFormat() {
std::ostringstream out;
Debug(&out) << ColorFormat::RGBA;
CORRADE_COMPARE(out.str(), "ColorFormat::RGBA\n");
Debug(&out) << PixelFormat::RGBA;
CORRADE_COMPARE(out.str(), "PixelFormat::RGBA\n");
}
void FormatTest::debugColorType() {
void FormatTest::debugPixelType() {
std::ostringstream out;
Debug(&out) << ColorType::UnsignedByte;
CORRADE_COMPARE(out.str(), "ColorType::UnsignedByte\n");
Debug(&out) << PixelType::UnsignedByte;
CORRADE_COMPARE(out.str(), "PixelType::UnsignedByte\n");
}
void FormatTest::debugCompressedColorFormat() {
void FormatTest::debugCompressedPixelFormat() {
#ifdef MAGNUM_TARGET_GLES
CORRADE_SKIP("No enum value available");
#else
std::ostringstream out;
Debug(&out) << CompressedColorFormat::RGBBptcUnsignedFloat;
CORRADE_COMPARE(out.str(), "CompressedColorFormat::RGBBptcUnsignedFloat\n");
Debug(&out) << CompressedPixelFormat::RGBBptcUnsignedFloat;
CORRADE_COMPARE(out.str(), "CompressedPixelFormat::RGBBptcUnsignedFloat\n");
#endif
}

16
src/Magnum/Test/FramebufferGLTest.cpp

@ -24,11 +24,11 @@
*/
#include "Magnum/configure.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Framebuffer.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Renderbuffer.h"
#include "Magnum/RenderbufferFormat.h"
#include "Magnum/Texture.h"
@ -860,7 +860,7 @@ void FramebufferGLTest::read() {
Renderer::setClearStencil(67);
framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil);
Image2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(colorImage.size(), Vector2i(8, 16));
@ -874,7 +874,7 @@ void FramebufferGLTest::read() {
Debug() << "Using" << Extensions::GL::NV::read_depth::string();
#endif
Image2D depthImage = framebuffer.read({{}, Vector2i{1}}, {ColorFormat::DepthComponent, ColorType::UnsignedShort});
Image2D depthImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::DepthComponent, PixelType::UnsignedShort});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(depthImage.data<UnsignedShort>()[0], 48352);
@ -888,7 +888,7 @@ void FramebufferGLTest::read() {
Debug() << "Using" << Extensions::GL::NV::read_stencil::string();
#endif
Image2D stencilImage = framebuffer.read({{}, Vector2i{1}}, {ColorFormat::StencilIndex, ColorType::UnsignedByte});
Image2D stencilImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::StencilIndex, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(stencilImage.data<UnsignedByte>()[0], 67);
@ -902,7 +902,7 @@ void FramebufferGLTest::read() {
Debug() << "Using" << Extensions::GL::NV::read_depth_stencil::string();
#endif
Image2D depthStencilImage = framebuffer.read({{}, Vector2i{1}}, {ColorFormat::DepthStencil, ColorType::UnsignedInt248});
Image2D depthStencilImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::DepthStencil, PixelType::UnsignedInt248});
MAGNUM_VERIFY_NO_ERROR();
/** @todo This will probably fail on different systems */
@ -937,7 +937,7 @@ void FramebufferGLTest::readBuffer() {
Renderer::setClearStencil(67);
framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil);
BufferImage2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
CORRADE_COMPARE(colorImage.size(), Vector2i(8, 16));
MAGNUM_VERIFY_NO_ERROR();
@ -986,14 +986,14 @@ void FramebufferGLTest::blit() {
b.clear(FramebufferClear::Color);
/* The framebuffer should be black before */
Image2D imageBefore = b.read({{}, Vector2i{1}}, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D imageBefore = b.read({{}, Vector2i{1}}, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(imageBefore.data<Color4ub>()[0], Color4ub());
/* And have given color after */
Framebuffer::blit(a, b, a.viewport(), FramebufferBlit::Color);
Image2D imageAfter = b.read({{}, Vector2i{1}}, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D imageAfter = b.read({{}, Vector2i{1}}, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(imageAfter.data<Color4ub>()[0], Color4ub(128, 64, 32, 17));

60
src/Magnum/Test/ImageTest.cpp

@ -25,8 +25,8 @@
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
namespace Magnum { namespace Test {
@ -66,19 +66,19 @@ ImageTest::ImageTest() {
void ImageTest::construct() {
auto data = new char[3];
Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
Image2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
CORRADE_COMPARE(a.format(), ColorFormat::Red);
CORRADE_COMPARE(a.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(a.format(), PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.data(), data);
}
void ImageTest::constructCompressed() {
auto data = new char[8];
CompressedImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CORRADE_COMPARE(a.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.size(), Vector2i(4, 4));
CORRADE_COMPARE(a.data(), data);
CORRADE_COMPARE(a.data().size(), 8);
@ -96,52 +96,52 @@ void ImageTest::constructCopyCompressed() {
void ImageTest::constructMove() {
auto data = new char[3];
Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
Image2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
Image2D b(std::move(a));
CORRADE_COMPARE(a.data(), nullptr);
CORRADE_COMPARE(a.size(), Vector2i());
CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.format(), PixelFormat::Red);
CORRADE_COMPARE(b.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_COMPARE(b.data(), data);
auto data2 = new char[12*4*2];
Image2D c(ColorFormat::RGBA, ColorType::UnsignedShort, {2, 6}, data2);
Image2D c(PixelFormat::RGBA, PixelType::UnsignedShort, {2, 6}, data2);
c = std::move(b);
CORRADE_COMPARE(b.data(), data2);
CORRADE_COMPARE(b.size(), Vector2i(2, 6));
CORRADE_COMPARE(c.format(), ColorFormat::Red);
CORRADE_COMPARE(c.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(c.format(), PixelFormat::Red);
CORRADE_COMPARE(c.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(c.size(), Vector2i(1, 3));
CORRADE_COMPARE(c.data(), data);
}
void ImageTest::constructMoveCompressed() {
auto data = new char[8];
CompressedImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImage2D b{std::move(a)};
CORRADE_COMPARE(a.data(), nullptr);
CORRADE_COMPARE(a.size(), Vector2i());
CORRADE_COMPARE(b.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.size(), Vector2i(4, 4));
CORRADE_COMPARE(b.data(), data);
CORRADE_COMPARE(b.data().size(), 8);
auto data2 = new char[16];
CompressedImage2D c{CompressedColorFormat::RGBAS3tcDxt3, {8, 4}, Containers::Array<char>{data2, 16}};
CompressedImage2D c{CompressedPixelFormat::RGBAS3tcDxt3, {8, 4}, Containers::Array<char>{data2, 16}};
c = std::move(b);
CORRADE_COMPARE_AS(b.data(), data2, char*);
CORRADE_COMPARE(b.data().size(), 16);
CORRADE_COMPARE(b.size(), Vector2i(8, 4));
CORRADE_COMPARE(c.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(c.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(c.size(), Vector2i(4, 4));
CORRADE_COMPARE(c.data(), data);
CORRADE_COMPARE(c.data().size(), 8);
@ -149,23 +149,23 @@ void ImageTest::constructMoveCompressed() {
void ImageTest::setData() {
auto data = new char[3];
Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
Image2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
auto data2 = new char[2*4];
a.setData(ColorFormat::RGBA, ColorType::UnsignedShort, {2, 1}, data2);
a.setData(PixelFormat::RGBA, PixelType::UnsignedShort, {2, 1}, data2);
CORRADE_COMPARE(a.format(), ColorFormat::RGBA);
CORRADE_COMPARE(a.type(), ColorType::UnsignedShort);
CORRADE_COMPARE(a.format(), PixelFormat::RGBA);
CORRADE_COMPARE(a.type(), PixelType::UnsignedShort);
CORRADE_COMPARE(a.size(), Vector2i(2, 1));
CORRADE_COMPARE(a.data(), data2);
}
void ImageTest::setDataCompressed() {
auto data = new char[8];
CompressedImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
auto data2 = new char[16];
a.setData(CompressedColorFormat::RGBAS3tcDxt3, {8, 4}, Containers::Array<char>{data2, 16});
a.setData(CompressedPixelFormat::RGBAS3tcDxt3, {8, 4}, Containers::Array<char>{data2, 16});
CORRADE_COMPARE(a.format(), CompressedColorFormat::RGBAS3tcDxt3);
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt3);
CORRADE_COMPARE(a.size(), Vector2i(8, 4));
CORRADE_COMPARE(a.data(), data2);
CORRADE_COMPARE(a.data().size(), 16);
@ -173,11 +173,11 @@ void ImageTest::setDataCompressed() {
void ImageTest::toReference() {
auto data = new char[3];
const Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
const Image2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
ImageView2D b = a;
CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.format(), PixelFormat::Red);
CORRADE_COMPARE(b.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_COMPARE(b.data(), data);
@ -193,10 +193,10 @@ void ImageTest::toReference() {
void ImageTest::toReferenceCommpressed() {
auto data = new char[8];
const CompressedImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
const CompressedImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImageView2D b = a;
CORRADE_COMPARE(b.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.size(), Vector2i(4, 4));
CORRADE_COMPARE(b.data(), data);
CORRADE_COMPARE(b.data().size(), 8);
@ -213,7 +213,7 @@ void ImageTest::toReferenceCommpressed() {
void ImageTest::release() {
char data[] = {'c', 'a', 'f', 'e'};
Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 4}, data);
Image2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 4}, data);
const char* const pointer = a.release();
CORRADE_COMPARE(pointer, data);
@ -223,7 +223,7 @@ void ImageTest::release() {
void ImageTest::releaseCompressed() {
char data[8];
CompressedImage2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImage2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
const char* const pointer = a.release().release();
CORRADE_COMPARE(pointer, data);

22
src/Magnum/Test/ImageViewTest.cpp

@ -25,8 +25,8 @@
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h"
namespace Magnum { namespace Test {
@ -50,42 +50,42 @@ ImageViewTest::ImageViewTest() {
void ImageViewTest::construct() {
const char data[3]{};
ImageView2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
ImageView2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
CORRADE_COMPARE(a.format(), ColorFormat::Red);
CORRADE_COMPARE(a.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(a.format(), PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.data(), data);
}
void ImageViewTest::constructCompressed() {
const char data[8]{};
CompressedImageView2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, data};
CompressedImageView2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, data};
CORRADE_COMPARE(a.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.size(), Vector2i(4, 4));
CORRADE_COMPARE(a.data(), data);
}
void ImageViewTest::setData() {
const char data[3]{};
ImageView2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
ImageView2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
const char data2[8]{};
a.setData(data2);
CORRADE_COMPARE(a.format(), ColorFormat::Red);
CORRADE_COMPARE(a.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(a.format(), PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.data(), data2);
}
void ImageViewTest::setDataCompressed() {
const char data[8]{};
CompressedImageView2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, data};
CompressedImageView2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, data};
const char data2[16]{};
a.setData(data2);
CORRADE_COMPARE(a.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.size(), Vector2i(4, 4));
CORRADE_COMPARE(a.data(), data2);
}

86
src/Magnum/Test/MeshGLTest.cpp

@ -25,11 +25,11 @@
#include "Magnum/AbstractShaderProgram.h"
#include "Magnum/Buffer.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/Framebuffer.h"
#include "Magnum/Image.h"
#include "Magnum/Mesh.h"
#include "Magnum/MeshView.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Renderbuffer.h"
#include "Magnum/RenderbufferFormat.h"
#include "Magnum/Shader.h"
@ -372,7 +372,7 @@ namespace {
struct Checker {
Checker(AbstractShaderProgram&& shader, RenderbufferFormat format, Mesh& mesh);
template<class T> T get(ColorFormat format, ColorType type);
template<class T> T get(PixelFormat format, PixelType type);
Renderbuffer renderbuffer;
Framebuffer framebuffer;
@ -500,7 +500,7 @@ Checker::Checker(AbstractShaderProgram&& shader, RenderbufferFormat format, Mesh
.draw(shader);
}
template<class T> T Checker::get(ColorFormat format, ColorType type) {
template<class T> T Checker::get(PixelFormat format, PixelType type) {
return framebuffer.read({{}, Vector2i{1}}, {format, type}).data<T>()[0];
}
#endif
@ -525,7 +525,7 @@ void MeshGLTest::addVertexBufferUnsignedInt() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R32UI, mesh)
.get<UnsignedInt>(ColorFormat::RedInteger, ColorType::UnsignedInt);
.get<UnsignedInt>(PixelFormat::RedInteger, PixelType::UnsignedInt);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 35681);
@ -550,7 +550,7 @@ void MeshGLTest::addVertexBufferInt() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("int"), RenderbufferFormat::R32I, mesh)
.get<Int>(ColorFormat::RedInteger, ColorType::Int);
.get<Int>(PixelFormat::RedInteger, PixelType::Int);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 27530);
@ -576,7 +576,7 @@ void MeshGLTest::addVertexBufferFloat() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<UnsignedByte>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<UnsignedByte>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 96);
@ -600,7 +600,7 @@ void MeshGLTest::addVertexBufferDouble() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(DoubleShader("double", "float", "float(value)"),
RenderbufferFormat::R16, mesh).get<UnsignedShort>(ColorFormat::Red, ColorType::UnsignedShort);
RenderbufferFormat::R16, mesh).get<UnsignedShort>(PixelFormat::Red, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 45828);
@ -627,7 +627,7 @@ void MeshGLTest::addVertexBufferVectorNui() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("uvec3"), RenderbufferFormat::RGBA32UI, mesh)
.get<Vector3ui>(ColorFormat::RGBAInteger, ColorType::UnsignedInt);
.get<Vector3ui>(PixelFormat::RGBAInteger, PixelType::UnsignedInt);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Vector3ui(27592, 157, 25));
@ -652,7 +652,7 @@ void MeshGLTest::addVertexBufferVectorNi() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("ivec2"), RenderbufferFormat::RG32I, mesh)
.get<Vector2i>(ColorFormat::RGInteger, ColorType::Int);
.get<Vector2i>(PixelFormat::RGInteger, PixelType::Int);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Vector2i(27592, -157));
@ -678,7 +678,7 @@ void MeshGLTest::addVertexBufferVectorN() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color3ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color3ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color3ub(96, 24, 156));
@ -705,7 +705,7 @@ void MeshGLTest::addVertexBufferVectorNd() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(DoubleShader("dvec4", "vec4", "vec4(value)"),
RenderbufferFormat::RGBA16, mesh).get<Math::Vector4<UnsignedShort>>(ColorFormat::RGBA, ColorType::UnsignedShort);
RenderbufferFormat::RGBA16, mesh).get<Math::Vector4<UnsignedShort>>(PixelFormat::RGBA, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Math::Vector4<UnsignedShort>(315, 65201, 2576, 12));
@ -731,7 +731,7 @@ void MeshGLTest::addVertexBufferMatrixNxN() {
const auto value = Checker(FloatShader("mat3",
"vec4(valueInterpolated[0][0], valueInterpolated[1][1], valueInterpolated[2][2], 0.0)"),
RenderbufferFormat::RGBA8, mesh).get<Color3ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
RenderbufferFormat::RGBA8, mesh).get<Color3ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color3ub(96, 24, 156));
@ -760,7 +760,7 @@ void MeshGLTest::addVertexBufferMatrixNxNd() {
const auto value = Checker(DoubleShader("dmat3", "vec4",
"vec4(value[0][0], value[1][1], value[2][2], 0.0)"),
RenderbufferFormat::RGBA16, mesh).get<Math::Vector3<UnsignedShort>>(ColorFormat::RGB, ColorType::UnsignedShort);
RenderbufferFormat::RGBA16, mesh).get<Math::Vector3<UnsignedShort>>(PixelFormat::RGB, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
@ -793,7 +793,7 @@ void MeshGLTest::addVertexBufferMatrixMxN() {
const auto value = Checker(FloatShader("mat3x4",
"vec4(valueInterpolated[0][0], valueInterpolated[1][1], valueInterpolated[2][2], 0.0)"),
RenderbufferFormat::RGBA8, mesh).get<Color3ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
RenderbufferFormat::RGBA8, mesh).get<Color3ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color3ub(96, 24, 156));
@ -823,7 +823,7 @@ void MeshGLTest::addVertexBufferMatrixMxNd() {
const auto value = Checker(DoubleShader("dmat3x4", "vec4",
"vec4(value[0][0], value[1][1], value[2][2], 0.0)"),
RenderbufferFormat::RGBA16, mesh).get<Math::Vector3<UnsignedShort>>(ColorFormat::RGB, ColorType::UnsignedShort);
RenderbufferFormat::RGBA16, mesh).get<Math::Vector3<UnsignedShort>>(PixelFormat::RGB, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
@ -856,7 +856,7 @@ void MeshGLTest::addVertexBufferUnsignedIntWithUnsignedShort() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R16UI, mesh)
.get<UnsignedShort>(ColorFormat::RedInteger, ColorType::UnsignedShort);
.get<UnsignedShort>(PixelFormat::RedInteger, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 16583);
@ -881,7 +881,7 @@ void MeshGLTest::addVertexBufferUnsignedIntWithShort() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R16I, mesh)
.get<Short>(ColorFormat::RedInteger, ColorType::Short);
.get<Short>(PixelFormat::RedInteger, PixelType::Short);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 16583);
@ -906,7 +906,7 @@ void MeshGLTest::addVertexBufferIntWithUnsignedShort() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("int"), RenderbufferFormat::R16UI, mesh)
.get<UnsignedShort>(ColorFormat::RedInteger, ColorType::UnsignedShort);
.get<UnsignedShort>(PixelFormat::RedInteger, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 16583);
@ -931,7 +931,7 @@ void MeshGLTest::addVertexBufferIntWithShort() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("int"), RenderbufferFormat::R16I, mesh)
.get<Short>(ColorFormat::RedInteger, ColorType::Short);
.get<Short>(PixelFormat::RedInteger, PixelType::Short);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, -16583);
@ -975,7 +975,7 @@ void MeshGLTest::addVertexBufferFloatWithDouble() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(FloatShader("float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"),
RenderbufferFormat::RGBA8, mesh).get<UnsignedByte>(ColorFormat::RGBA, ColorType::UnsignedShort);
RenderbufferFormat::RGBA8, mesh).get<UnsignedByte>(PixelFormat::RGBA, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 186);
@ -1063,7 +1063,7 @@ void MeshGLTest::addVertexBufferLessVectorComponents() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color4ub(96, 24, 156, 255));
@ -1088,7 +1088,7 @@ void MeshGLTest::addVertexBufferNormalized() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color3ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color3ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color3ub(32, 156, 228));
@ -1114,7 +1114,7 @@ void MeshGLTest::addVertexBufferBGRA() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(FloatShader("vec4", "valueInterpolated"),
RenderbufferFormat::RGBA8, mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
RenderbufferFormat::RGBA8, mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color4ub(156, 24, 96, 225));
@ -1200,7 +1200,7 @@ void MeshGLTest::addVertexBufferMultiple() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color4ub(64 + 15 + 97, 17 + 164 + 28, 56 + 17, 255));
@ -1243,7 +1243,7 @@ void MeshGLTest::addVertexBufferMultipleGaps() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, Color4ub(64 + 15 + 97, 17 + 164 + 28, 56 + 17, 255));
@ -1324,7 +1324,7 @@ void MeshGLTest::setIndexBuffer() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1351,7 +1351,7 @@ void MeshGLTest::setIndexBufferRange() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1383,7 +1383,7 @@ void MeshGLTest::setIndexBufferUnsignedInt() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1410,7 +1410,7 @@ void MeshGLTest::setBaseVertex() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(MultipleShader{}, RenderbufferFormat::RGBA8,
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1450,7 +1450,7 @@ void MeshGLTest::setInstanceCount() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<UnsignedByte>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<UnsignedByte>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 96);
@ -1491,7 +1491,7 @@ void MeshGLTest::setInstanceCountIndexed() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1525,7 +1525,7 @@ void MeshGLTest::setInstanceCountBaseInstance() {
const auto value = Checker(FloatShader("float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"),
RenderbufferFormat::RGBA8,
mesh).get<UnsignedByte>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<UnsignedByte>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 96);
@ -1559,7 +1559,7 @@ void MeshGLTest::setInstanceCountBaseInstanceIndexed() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(MultipleShader{}, RenderbufferFormat::RGBA8,
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1593,7 +1593,7 @@ void MeshGLTest::setInstanceCountBaseVertex() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(MultipleShader{}, RenderbufferFormat::RGBA8,
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1630,7 +1630,7 @@ void MeshGLTest::setInstanceCountBaseVertexBaseInstance() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(MultipleShader{}, RenderbufferFormat::RGBA8,
mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1674,7 +1674,7 @@ void MeshGLTest::addVertexBufferInstancedFloat() {
#else
RenderbufferFormat::RGBA4,
#endif
mesh).get<UnsignedByte>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<UnsignedByte>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 96);
@ -1710,7 +1710,7 @@ void MeshGLTest::addVertexBufferInstancedInteger() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R32UI, mesh)
.get<UnsignedInt>(ColorFormat::RedInteger, ColorType::UnsignedInt);
.get<UnsignedInt>(PixelFormat::RedInteger, PixelType::UnsignedInt);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 35681);
@ -1745,7 +1745,7 @@ void MeshGLTest::addVertexBufferInstancedDouble() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = Checker(DoubleShader("double", "float", "float(value)"),
RenderbufferFormat::R16, mesh).get<UnsignedShort>(ColorFormat::Red, ColorType::UnsignedShort);
RenderbufferFormat::R16, mesh).get<UnsignedShort>(PixelFormat::Red, PixelType::UnsignedShort);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 45828);
@ -1756,7 +1756,7 @@ namespace {
struct MultiChecker {
MultiChecker(AbstractShaderProgram&& shader, Mesh& mesh);
template<class T> T get(ColorFormat format, ColorType type);
template<class T> T get(PixelFormat format, PixelType type);
Renderbuffer renderbuffer;
Framebuffer framebuffer;
@ -1793,7 +1793,7 @@ MultiChecker::MultiChecker(AbstractShaderProgram&& shader, Mesh& mesh): framebuf
MeshView::draw(shader, {a, b});
}
template<class T> T MultiChecker::get(ColorFormat format, ColorType type) {
template<class T> T MultiChecker::get(PixelFormat format, PixelType type) {
return framebuffer.read({{}, Vector2i{1}}, {format, type}).data<T>()[0];
}
#endif
@ -1816,7 +1816,7 @@ void MeshGLTest::multiDraw() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = MultiChecker(FloatShader("float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"),
mesh).get<UnsignedByte>(ColorFormat::RGBA, ColorType::UnsignedByte);
mesh).get<UnsignedByte>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, 96);
@ -1842,7 +1842,7 @@ void MeshGLTest::multiDrawIndexed() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = MultiChecker(MultipleShader{}, mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
const auto value = MultiChecker(MultipleShader{}, mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);
@ -1868,7 +1868,7 @@ void MeshGLTest::multiDrawBaseVertex() {
MAGNUM_VERIFY_NO_ERROR();
const auto value = MultiChecker(MultipleShader{}, mesh).get<Color4ub>(ColorFormat::RGBA, ColorType::UnsignedByte);
const auto value = MultiChecker(MultipleShader{}, mesh).get<Color4ub>(PixelFormat::RGBA, PixelType::UnsignedByte);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(value, indexedResult);

20
src/Magnum/Test/PixelStorageTest.cpp

@ -26,7 +26,7 @@
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/Image.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/PixelStorage.h"
namespace Magnum { namespace Test {
@ -44,20 +44,20 @@ PixelStorageTest::PixelStorageTest() {
}
void PixelStorageTest::pixelSize() {
CORRADE_COMPARE(Implementation::imagePixelSize(ColorFormat::RGBA, ColorType::UnsignedInt), 4*4);
CORRADE_COMPARE(Implementation::imagePixelSize(ColorFormat::DepthComponent, ColorType::UnsignedShort), 2);
CORRADE_COMPARE(Implementation::imagePixelSize(ColorFormat::StencilIndex, ColorType::UnsignedByte), 1);
CORRADE_COMPARE(Implementation::imagePixelSize(ColorFormat::DepthStencil, ColorType::UnsignedInt248), 4);
CORRADE_COMPARE(Implementation::imagePixelSize(PixelFormat::RGBA, PixelType::UnsignedInt), 4*4);
CORRADE_COMPARE(Implementation::imagePixelSize(PixelFormat::DepthComponent, PixelType::UnsignedShort), 2);
CORRADE_COMPARE(Implementation::imagePixelSize(PixelFormat::StencilIndex, PixelType::UnsignedByte), 1);
CORRADE_COMPARE(Implementation::imagePixelSize(PixelFormat::DepthStencil, PixelType::UnsignedInt248), 4);
}
void PixelStorageTest::dataSize() {
/* Verify that row size is properly rounded */
CORRADE_COMPARE(Image2D(ColorFormat::RGBA, ColorType::UnsignedByte).dataSize({}), 0);
CORRADE_COMPARE(Image2D(ColorFormat::Red, ColorType::UnsignedByte).dataSize({4, 2}), 8);
CORRADE_COMPARE(Image2D(ColorFormat::Red, ColorType::UnsignedByte).dataSize({2, 4}), 16);
CORRADE_COMPARE(Image2D(ColorFormat::RGBA, ColorType::UnsignedByte).dataSize(Vector2i(1)), 4);
CORRADE_COMPARE(Image2D(PixelFormat::RGBA, PixelType::UnsignedByte).dataSize({}), 0);
CORRADE_COMPARE(Image2D(PixelFormat::Red, PixelType::UnsignedByte).dataSize({4, 2}), 8);
CORRADE_COMPARE(Image2D(PixelFormat::Red, PixelType::UnsignedByte).dataSize({2, 4}), 16);
CORRADE_COMPARE(Image2D(PixelFormat::RGBA, PixelType::UnsignedByte).dataSize(Vector2i(1)), 4);
CORRADE_COMPARE(Image2D(ColorFormat::RGBA, ColorType::UnsignedShort).dataSize({16, 8}),
CORRADE_COMPARE(Image2D(PixelFormat::RGBA, PixelType::UnsignedShort).dataSize({16, 8}),
4*2*16*8);
}

30
src/Magnum/Test/RectangleTextureGLTest.cpp

@ -28,8 +28,8 @@
#include "Magnum/configure.h"
#include "Magnum/BufferImage.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/RectangleTexture.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Color.h"
@ -261,11 +261,11 @@ void RectangleTextureGLTest::image() {
RectangleTexture texture;
texture.setImage(TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.image({ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -285,11 +285,11 @@ void RectangleTextureGLTest::imageBuffer() {
RectangleTexture texture;
texture.setImage(TextureFormat::RGBA8,
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.image({ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -319,13 +319,13 @@ void RectangleTextureGLTest::subImage() {
RectangleTexture texture;
texture.setImage(TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setSubImage(Vector2i(1),
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data));
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.image({ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -345,13 +345,13 @@ void RectangleTextureGLTest::subImageBuffer() {
RectangleTexture texture;
texture.setImage(TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
texture.setSubImage(Vector2i(1),
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.image({ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -372,11 +372,11 @@ void RectangleTextureGLTest::subImageQuery() {
RectangleTexture texture;
texture.setStorage(TextureFormat::RGBA8, Vector2i{4})
.setSubImage({}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubDataComplete});
.setSubImage({}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubDataComplete});
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -394,11 +394,11 @@ void RectangleTextureGLTest::subImageQueryBuffer() {
RectangleTexture texture;
texture.setStorage(TextureFormat::RGBA8, Vector2i{4})
.setSubImage({}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubDataComplete});
.setSubImage({}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubDataComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();

74
src/Magnum/Test/TextureArrayGLTest.cpp

@ -27,8 +27,8 @@
#include "Magnum/configure.h"
#include "Magnum/BufferImage.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/TextureArray.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Color.h"
@ -667,11 +667,11 @@ void TextureArrayGLTest::image1D() {
Texture1DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data1D));
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -691,11 +691,11 @@ void TextureArrayGLTest::image1DBuffer() {
Texture1DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data1D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -736,13 +736,13 @@ void TextureArrayGLTest::image2D() {
Texture2DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data2D));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -767,7 +767,7 @@ void TextureArrayGLTest::compressedImage2D() {
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D});
MAGNUM_VERIFY_NO_ERROR();
@ -792,13 +792,13 @@ void TextureArrayGLTest::image2DBuffer() {
Texture2DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D, BufferUsage::StaticDraw));
BufferImage3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data2D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -822,7 +822,7 @@ void TextureArrayGLTest::compressedImage2DBuffer() {
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D});
MAGNUM_VERIFY_NO_ERROR();
@ -855,13 +855,13 @@ void TextureArrayGLTest::subImage1D() {
Texture1DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero1D));
texture.setSubImage(0, Vector2i(1),
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data1D));
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -881,13 +881,13 @@ void TextureArrayGLTest::subImage1DBuffer() {
Texture1DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero1D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero1D));
texture.setSubImage(0, Vector2i(1),
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data1D, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data1D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -908,11 +908,11 @@ void TextureArrayGLTest::subImage1DQuery() {
Texture1DArray texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
.setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData1DComplete});
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubData1DComplete});
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -929,11 +929,11 @@ void TextureArrayGLTest::subImage1DQueryBuffer() {
Texture1DArray texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
.setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData1DComplete});
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubData1DComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1011,15 +1011,15 @@ void TextureArrayGLTest::subImage2D() {
Texture2DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(4), Zero2D));
texture.setSubImage(0, Vector3i(1),
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data2D));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1043,9 +1043,9 @@ void TextureArrayGLTest::compressedSubImage2D() {
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector3i{12, 4, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D(CompressedPixelFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D));
MAGNUM_VERIFY_NO_ERROR();
@ -1069,15 +1069,15 @@ void TextureArrayGLTest::subImage2DBuffer() {
Texture2DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero2D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(4), Zero2D));
texture.setSubImage(0, Vector3i(1),
BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data2D, BufferUsage::StaticDraw));
BufferImage3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data2D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1101,9 +1101,9 @@ void TextureArrayGLTest::compressedSubImage2DBuffer() {
#endif
Texture2DArray texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector3i{12, 4, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D(CompressedPixelFormat::RGBAS3tcDxt3,
{4, 4, 2}, CompressedData2D));
MAGNUM_VERIFY_NO_ERROR();
@ -1128,11 +1128,11 @@ void TextureArrayGLTest::subImage2DQuery() {
Texture2DArray texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData2DComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{4}, SubData2DComplete});
MAGNUM_VERIFY_NO_ERROR();
Image3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1149,11 +1149,11 @@ void TextureArrayGLTest::subImage2DQueryBuffer() {
Texture2DArray texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData2DComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{4}, SubData2DComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1170,7 +1170,7 @@ void TextureArrayGLTest::generateMipmap1D() {
Texture1DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
CORRADE_COMPARE(texture.imageSize(1), Vector2i( 0));
@ -1200,7 +1200,7 @@ void TextureArrayGLTest::generateMipmap2D() {
Texture2DArray texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(32)));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(32)));
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES

116
src/Magnum/Test/TextureGLTest.cpp

@ -29,8 +29,8 @@
#ifndef MAGNUM_TARGET_GLES2
#include "Magnum/BufferImage.h"
#endif
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Texture.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Color.h"
@ -907,11 +907,11 @@ namespace {
void TextureGLTest::image1D() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D));
ImageView1D(PixelFormat::RGBA, PixelType::UnsignedByte, 2, Data1D));
MAGNUM_VERIFY_NO_ERROR();
Image1D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image1D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -928,11 +928,11 @@ void TextureGLTest::compressedImage1D() {
void TextureGLTest::image1DBuffer() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw));
BufferImage1D(PixelFormat::RGBA, PixelType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage1D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticDraw);
BufferImage1D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticDraw);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -962,13 +962,13 @@ namespace {
void TextureGLTest::image2D() {
Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data2D));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -989,7 +989,7 @@ void TextureGLTest::compressedImage2D() {
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D});
MAGNUM_VERIFY_NO_ERROR();
@ -1011,13 +1011,13 @@ void TextureGLTest::compressedImage2D() {
void TextureGLTest::image2DBuffer() {
Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8,
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1037,7 +1037,7 @@ void TextureGLTest::compressedImage2DBuffer() {
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedBufferImage2D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -1085,13 +1085,13 @@ void TextureGLTest::image3D() {
Texture3D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data3D));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1116,7 +1116,7 @@ void TextureGLTest::compressedImage3D() {
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D});
MAGNUM_VERIFY_NO_ERROR();
@ -1137,13 +1137,13 @@ void TextureGLTest::compressedImage3D() {
void TextureGLTest::image3DBuffer() {
Texture3D texture;
texture.setImage(0, TextureFormat::RGBA8,
BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw));
BufferImage3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1163,7 +1163,7 @@ void TextureGLTest::compressedImage3DBuffer() {
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedBufferImage3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedBufferImage3D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -1191,13 +1191,13 @@ namespace {
void TextureGLTest::subImage1D() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D));
ImageView1D(PixelFormat::RGBA, PixelType::UnsignedByte, 4, Zero1D));
texture.setSubImage(0, 1,
ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D));
ImageView1D(PixelFormat::RGBA, PixelType::UnsignedByte, 2, Data1D));
MAGNUM_VERIFY_NO_ERROR();
Image1D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image1D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1214,13 +1214,13 @@ void TextureGLTest::compressedSubImage1D() {
void TextureGLTest::subImage1DBuffer() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 4, Zero1D));
ImageView1D(PixelFormat::RGBA, PixelType::UnsignedByte, 4, Zero1D));
texture.setSubImage(0, 1,
BufferImage1D(ColorFormat::RGBA, ColorType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw));
BufferImage1D(PixelFormat::RGBA, PixelType::UnsignedByte, 2, Data1D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage1D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage1D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1239,11 +1239,11 @@ void TextureGLTest::subImage1DQuery() {
Texture1D texture;
texture.setStorage(1, TextureFormat::RGBA8, 4)
.setSubImage(0, {}, ImageView1D{ColorFormat::RGBA, ColorType::UnsignedByte, 4, SubData1DComplete});
.setSubImage(0, {}, ImageView1D{PixelFormat::RGBA, PixelType::UnsignedByte, 4, SubData1DComplete});
MAGNUM_VERIFY_NO_ERROR();
Image1D image = texture.subImage(0, Range1Di::fromSize(1, 2), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image1D image = texture.subImage(0, Range1Di::fromSize(1, 2), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1258,11 +1258,11 @@ void TextureGLTest::subImage1DQueryBuffer() {
Texture1D texture;
texture.setStorage(1, TextureFormat::RGBA8, 4)
.setSubImage(0, {}, ImageView1D{ColorFormat::RGBA, ColorType::UnsignedByte, 4, SubData1DComplete});
.setSubImage(0, {}, ImageView1D{PixelFormat::RGBA, PixelType::UnsignedByte, 4, SubData1DComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage1D image = texture.subImage(0, Range1Di::fromSize(1, 2), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage1D image = texture.subImage(0, Range1Di::fromSize(1, 2), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1299,15 +1299,15 @@ namespace {
void TextureGLTest::subImage2D() {
Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero2D));
texture.setSubImage(0, Vector2i(1),
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data2D));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1328,9 +1328,9 @@ void TextureGLTest::compressedSubImage2D() {
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3,
{12, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0}, CompressedImageView2D(CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedSubImage(0, {4, 0}, CompressedImageView2D(CompressedPixelFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D));
MAGNUM_VERIFY_NO_ERROR();
@ -1351,15 +1351,15 @@ void TextureGLTest::compressedSubImage2D() {
void TextureGLTest::subImage2DBuffer() {
Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero2D));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero2D));
texture.setSubImage(0, Vector2i(1),
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw));
BufferImage2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Data2D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1379,9 +1379,9 @@ void TextureGLTest::compressedSubImage2DBuffer() {
#endif
Texture2D texture;
texture.setCompressedImage(0, CompressedImageView2D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3,
{12, 4}, CompressedZero2D});
texture.setCompressedSubImage(0, {4, 0}, CompressedBufferImage2D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedSubImage(0, {4, 0}, CompressedBufferImage2D{CompressedPixelFormat::RGBAS3tcDxt3,
Vector2i{4}, CompressedData2D, BufferUsage::StaticDraw});
MAGNUM_VERIFY_NO_ERROR();
@ -1405,11 +1405,11 @@ void TextureGLTest::subImage2DQuery() {
Texture2D texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
.setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData2DComplete});
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubData2DComplete});
MAGNUM_VERIFY_NO_ERROR();
Image2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1424,11 +1424,11 @@ void TextureGLTest::subImage2DQueryBuffer() {
Texture2D texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
.setSubImage(0, {}, ImageView2D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i{4}, SubData2DComplete});
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubData2DComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage2D image = texture.subImage(0, Range2Di::fromSize(Vector2i{1}, Vector2i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1507,15 +1507,15 @@ void TextureGLTest::subImage3D() {
Texture3D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(4), Zero3D));
texture.setSubImage(0, Vector3i(1),
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data3D));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1540,9 +1540,9 @@ void TextureGLTest::compressedSubImage3D() {
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{12, 4, 4}, CompressedZero3D});
texture.setCompressedSubImage(0, {4, 0, 0}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedSubImage(0, {4, 0, 0}, CompressedImageView3D(CompressedPixelFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D));
MAGNUM_VERIFY_NO_ERROR();
@ -1563,15 +1563,15 @@ void TextureGLTest::compressedSubImage3D() {
void TextureGLTest::subImage3DBuffer() {
Texture3D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(4), Zero3D));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(4), Zero3D));
texture.setSubImage(0, Vector3i(1),
BufferImage3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw));
BufferImage3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(2), Data3D, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1591,9 +1591,9 @@ void TextureGLTest::compressedSubImage3DBuffer() {
#endif
Texture3D texture;
texture.setCompressedImage(0, CompressedImageView3D{CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3,
{12, 4, 4}, CompressedZero3D});
texture.setCompressedSubImage(0, {4, 0, 0}, CompressedImageView3D(CompressedColorFormat::RGBAS3tcDxt3,
texture.setCompressedSubImage(0, {4, 0, 0}, CompressedImageView3D(CompressedPixelFormat::RGBAS3tcDxt3,
Vector3i{4}, CompressedData3D));
MAGNUM_VERIFY_NO_ERROR();
@ -1617,11 +1617,11 @@ void TextureGLTest::subImage3DQuery() {
Texture3D texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData3DComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{4}, SubData3DComplete});
MAGNUM_VERIFY_NO_ERROR();
Image3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte});
Image3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte});
MAGNUM_VERIFY_NO_ERROR();
@ -1636,11 +1636,11 @@ void TextureGLTest::subImage3DQueryBuffer() {
Texture3D texture;
texture.setStorage(1, TextureFormat::RGBA8, Vector3i{4})
.setSubImage(0, {}, ImageView3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{4}, SubData3DComplete});
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i{4}, SubData3DComplete});
MAGNUM_VERIFY_NO_ERROR();
BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
BufferImage3D image = texture.subImage(0, Range3Di::fromSize(Vector3i{1}, Vector3i{2}), {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
@ -1655,7 +1655,7 @@ void TextureGLTest::generateMipmap1D() {
Texture1D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView1D(ColorFormat::RGBA, ColorType::UnsignedByte, 32));
ImageView1D(PixelFormat::RGBA, PixelType::UnsignedByte, 32));
CORRADE_COMPARE(texture.imageSize(0), 32);
CORRADE_COMPARE(texture.imageSize(1), 0);
@ -1683,7 +1683,7 @@ void TextureGLTest::generateMipmap2D() {
Texture2D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
@ -1719,7 +1719,7 @@ void TextureGLTest::generateMipmap3D() {
Texture3D texture;
texture.setImage(0, TextureFormat::RGBA8,
ImageView3D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i(32)));
ImageView3D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector3i(32)));
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES

30
src/Magnum/Text/DistanceFieldGlyphCache.cpp

@ -25,12 +25,12 @@
#include "DistanceFieldGlyphCache.h"
#ifndef CORRADE_NO_ASSERT
#include "Magnum/ColorFormat.h"
#endif
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/ImageView.h"
#ifndef CORRADE_NO_ASSERT
#include "Magnum/PixelFormat.h"
#endif
#include "Magnum/TextureFormat.h"
#include "Magnum/TextureTools/DistanceField.h"
@ -62,21 +62,21 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c
void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageView2D& image) {
#if !(defined(MAGNUM_TARGET_GLES) && defined(MAGNUM_TARGET_GLES2))
const TextureFormat internalFormat = TextureFormat::R8;
CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
CORRADE_ASSERT(image.format() == PixelFormat::Red,
"Text::DistanceFieldGlyphCache::setImage(): expected" << PixelFormat::Red << "but got" << image.format(), );
#else
TextureFormat internalFormat;
#ifndef MAGNUM_TARGET_WEBGL
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>()) {
internalFormat = TextureFormat::Red;
CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
CORRADE_ASSERT(image.format() == PixelFormat::Red,
"Text::DistanceFieldGlyphCache::setImage(): expected" << PixelFormat::Red << "but got" << image.format(), );
} else
#endif
{
internalFormat = TextureFormat::Luminance;
CORRADE_ASSERT(image.format() == ColorFormat::Luminance,
"Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Luminance << "but got" << image.format(), );
CORRADE_ASSERT(image.format() == PixelFormat::Luminance,
"Text::DistanceFieldGlyphCache::setImage(): expected" << PixelFormat::Luminance << "but got" << image.format(), );
}
#endif
@ -92,19 +92,19 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageView2D
void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageView2D& image) {
#if !(defined(MAGNUM_TARGET_GLES) && defined(MAGNUM_TARGET_GLES2))
CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
CORRADE_ASSERT(image.format() == PixelFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << PixelFormat::Red << "but got" << image.format(), );
#else
#ifndef MAGNUM_TARGET_WEBGL
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>())
CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
CORRADE_ASSERT(image.format() == PixelFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << PixelFormat::Red << "but got" << image.format(), );
else
#endif
{
/* Luminance is not renderable in most cases */
CORRADE_ASSERT(image.format() == ColorFormat::RGB,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::RGB << "but got" << image.format(), );
CORRADE_ASSERT(image.format() == PixelFormat::RGB,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << PixelFormat::RGB << "but got" << image.format(), );
}
#endif

16
src/Magnum/Texture.h

@ -70,7 +70,7 @@ Common usage is to fully configure all texture parameters and then set the
data from e.g. @ref Image. Example configuration of high quality texture with
trilinear anisotropic filtering, i.e. the best you can ask for:
@code
Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {4096, 4096}, data);
Image2D image(PixelFormat::RGBA, PixelType::UnsignedByte, {4096, 4096}, data);
Texture2D texture;
texture.setMagnificationFilter(Sampler::Filter::Linear)
@ -598,7 +598,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_extension{TextureStorage3D,EXT,direct_state_access},
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexStorage1D}/@fn_gl{TexStorage2D}/@fn_gl{TexStorage3D}
* @todo allow the user to specify ColorType explicitly to avoid
* @todo allow the user to specify PixelType explicitly to avoid
* issues in WebGL (see setSubImage())
*/
Texture<dimensions>& setStorage(Int levels, TextureFormat internalFormat, const VectorTypeFor<dimensions, Int>& size) {
@ -667,7 +667,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image<dimensions> image(Int level, Image<dimensions>&& image);
@ -692,7 +692,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage2D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage<dimensions> image(Int level, BufferImage<dimensions>&& image, BufferUsage usage);
@ -786,7 +786,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = texture.subImage(0, rect, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image2D image = texture.subImage(0, rect, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image<dimensions> subImage(Int level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>&& image);
@ -812,7 +812,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = texture.subImage(0, rect, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage2D image = texture.subImage(0, rect, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage<dimensions> subImage(Int level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>&& image, BufferUsage usage);
@ -938,10 +938,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access},
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexSubImage1D} / @fn_gl{TexSubImage2D} / @fn_gl{TexSubImage3D}
* @requires_gles In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref ColorType
* @requires_gles In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref PixelType
* of data passed in @p image must match the original one
* specified in @ref setImage(). It means that you might not be
* able to use @ref setStorage() as it uses implicit @ref ColorType
* able to use @ref setStorage() as it uses implicit @ref PixelType
* value.
*/
Texture<dimensions>& setSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, const ImageView<dimensions>& image) {

10
src/Magnum/TextureArray.h

@ -74,7 +74,7 @@ calling @ref setStorage() and then specify each layer separately using
texture.setStorage(levels, TextureFormat::RGBA8, {64, 64, 16});
for(std::size_t i = 0; i != 16; ++i) {
Image3D image(ColorFormat::RGBA, ColorType::UnsignedByte, {64, 64, 1}, ...);
Image3D image(PixelFormat::RGBA, PixelType::UnsignedByte, {64, 64, 1}, ...);
texture.setSubImage(0, Vector3i::zAxis(i), image);
}
@endcode
@ -409,7 +409,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image<dimensions+1> image(Int level, Image<dimensions+1>&& image);
@ -431,7 +431,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage3D image = texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage<dimensions+1> image(Int level, BufferImage<dimensions+1>&& image, BufferUsage usage);
@ -497,7 +497,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* Image3D image = texture.subImage(0, range, {ColorFormat::RGBA, ColorType::UnsignedByte});
* Image3D image = texture.subImage(0, range, {PixelFormat::RGBA, PixelType::UnsignedByte});
* @endcode
*/
Image<dimensions+1> subImage(Int level, const RangeTypeFor<dimensions+1, Int>& range, Image<dimensions+1>&& image);
@ -519,7 +519,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage3D image = texture.subImage(0, range, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* BufferImage3D image = texture.subImage(0, range, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage<dimensions+1> subImage(Int level, const RangeTypeFor<dimensions+1, Int>& range, BufferImage<dimensions+1>&& image, BufferUsage usage);

4
src/Magnum/TextureFormat.h

@ -38,8 +38,8 @@ namespace Magnum {
In most cases you may want to use @ref TextureFormat::R8 (for grayscale
textures), @ref TextureFormat::RGB8 or @ref TextureFormat::RGBA8. The matching
color format is then @ref ColorFormat::Red, @ref ColorFormat::RGB or
@ref ColorFormat::RGBA along with @ref ColorType::UnsignedByte. See
color format is then @ref PixelFormat::Red, @ref PixelFormat::RGB or
@ref PixelFormat::RGBA along with @ref PixelType::UnsignedByte. See
documentation of these values for possible limitations when using OpenGL ES 2.0
or WebGL.

12
src/Magnum/TextureTools/distancefieldconverter.cpp

@ -28,8 +28,8 @@
#include <Corrade/PluginManager/Manager.h>
#include "Magnum/Math/Range.h"
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Renderer.h"
#include "Magnum/Texture.h"
#include "Magnum/TextureFormat.h"
@ -71,7 +71,7 @@ Arguments:
- `--output-size "X Y"` -- size of output image
- `--radius N` -- distance field computation radius
Images with @ref ColorFormat::Red, @ref ColorFormat::RGB or @ref ColorFormat::RGBA
Images with @ref PixelFormat::Red, @ref PixelFormat::RGB or @ref PixelFormat::RGBA
are accepted on input.
The resulting image can be then used with @ref Shaders::DistanceFieldVector
@ -136,9 +136,9 @@ int DistanceFieldConverter::exec() {
/* Decide about internal format */
TextureFormat internalFormat;
if(image->format() == ColorFormat::Red) internalFormat = TextureFormat::R8;
else if(image->format() == ColorFormat::RGB) internalFormat = TextureFormat::RGB8;
else if(image->format() == ColorFormat::RGBA) internalFormat = TextureFormat::RGBA8;
if(image->format() == PixelFormat::Red) internalFormat = TextureFormat::R8;
else if(image->format() == PixelFormat::RGB) internalFormat = TextureFormat::RGB8;
else if(image->format() == PixelFormat::RGBA) internalFormat = TextureFormat::RGBA8;
else {
Error() << "Unsupported image format" << image->format();
return 1;
@ -163,7 +163,7 @@ int DistanceFieldConverter::exec() {
TextureTools::distanceField(input, output, {{}, args.value<Vector2i>("output-size")}, args.value<Int>("radius"), image->size());
/* Save image */
Image2D result(ColorFormat::Red, ColorType::UnsignedByte);
Image2D result(PixelFormat::Red, PixelType::UnsignedByte);
output.image(0, result);
if(!converter->exportToFile(result, args.value("output"))) {
Error() << "Cannot save file" << args.value("output");

6
src/Magnum/Trade/ImageData.cpp

@ -27,17 +27,17 @@
namespace Magnum { namespace Trade {
template<UnsignedInt dimensions> ColorFormat ImageData<dimensions>::format() const {
template<UnsignedInt dimensions> PixelFormat ImageData<dimensions>::format() const {
CORRADE_ASSERT(!_compressed, "Trade::ImageData::format(): the image is compressed", {});
return _format;
}
template<UnsignedInt dimensions> ColorType ImageData<dimensions>::type() const {
template<UnsignedInt dimensions> PixelType ImageData<dimensions>::type() const {
CORRADE_ASSERT(!_compressed, "Trade::ImageData::type(): the image is compressed", {});
return _type;
}
template<UnsignedInt dimensions> CompressedColorFormat ImageData<dimensions>::compressedFormat() const {
template<UnsignedInt dimensions> CompressedPixelFormat ImageData<dimensions>::compressedFormat() const {
CORRADE_ASSERT(_compressed, "Trade::ImageData::format(): the image is not compressed", {});
return _compressedFormat;
}

16
src/Magnum/Trade/ImageData.h

@ -66,7 +66,7 @@ template<UnsignedInt dimensions> class ImageData {
* Note that the image data are not copied on construction, but they
* are deleted on class destruction.
*/
explicit ImageData(ColorFormat format, ColorType type, const VectorTypeFor<dimensions, Int>& size, void* data): _compressed{false}, _format{format}, _type{type}, _size{size}, _data{reinterpret_cast<char*>(data), dataSize(size)} {}
explicit ImageData(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size, void* data): _compressed{false}, _format{format}, _type{type}, _size{size}, _data{reinterpret_cast<char*>(data), dataSize(size)} {}
/**
* @brief Construct compressed image data
@ -77,7 +77,7 @@ template<UnsignedInt dimensions> class ImageData {
* Note that the image data are not copied on construction, but they
* are deleted on class destruction.
*/
explicit ImageData(CompressedColorFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data): _compressed{true}, _compressedFormat{format}, _size{size}, _data{std::move(data)} {}
explicit ImageData(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::Array<char>&& data): _compressed{true}, _compressedFormat{format}, _size{size}, _data{std::move(data)} {}
/** @brief Copying is not allowed */
ImageData(const ImageData<dimensions>&) = delete;
@ -136,7 +136,7 @@ template<UnsignedInt dimensions> class ImageData {
* The image is expected to be uncompressed.
* @see @ref isCompressed()
*/
ColorFormat format() const;
PixelFormat format() const;
/**
* @brief Data type of pixel data
@ -144,7 +144,7 @@ template<UnsignedInt dimensions> class ImageData {
* The image is expected to be uncompressed.
* @see @ref isCompressed()
*/
ColorType type() const;
PixelType type() const;
/**
* @brief Format of compressed data
@ -152,7 +152,7 @@ template<UnsignedInt dimensions> class ImageData {
* The image is expected to be compressed.
* @see @ref isCompressed()
*/
CompressedColorFormat compressedFormat() const;
CompressedPixelFormat compressedFormat() const;
/**
* @brief Pixel size (in bytes)
@ -206,10 +206,10 @@ template<UnsignedInt dimensions> class ImageData {
private:
bool _compressed;
union {
ColorFormat _format;
CompressedColorFormat _compressedFormat;
PixelFormat _format;
CompressedPixelFormat _compressedFormat;
};
ColorType _type;
PixelType _type;
Math::Vector<Dimensions, Int> _size;
Containers::Array<char> _data;
};

4
src/Magnum/Trade/Test/AbstractImageConverterTest.cpp

@ -28,8 +28,8 @@
#include <Corrade/TestSuite/Compare/FileToString.h>
#include <Corrade/Utility/Directory.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Trade/AbstractImageConverter.h"
#include "configure.h"
@ -62,7 +62,7 @@ void AbstractImageConverterTest::exportToFile() {
/* doExportToFile() should call doExportToData() */
DataExporter exporter;
ImageView2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {0xfe, 0xed}, nullptr);
ImageView2D image(PixelFormat::RGBA, PixelType::UnsignedByte, {0xfe, 0xed}, nullptr);
CORRADE_VERIFY(exporter.exportToFile(image, Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out")));
CORRADE_COMPARE_AS(Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"),
"\xFE\xED", TestSuite::Compare::FileToString);

46
src/Magnum/Trade/Test/ImageDataTest.cpp

@ -25,7 +25,7 @@
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Trade/ImageData.h"
namespace Magnum { namespace Trade { namespace Test {
@ -61,21 +61,21 @@ ImageDataTest::ImageDataTest() {
void ImageDataTest::construct() {
auto data = new char[3];
Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
Trade::ImageData2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
CORRADE_VERIFY(!a.isCompressed());
CORRADE_COMPARE(a.format(), ColorFormat::Red);
CORRADE_COMPARE(a.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(a.format(), PixelFormat::Red);
CORRADE_COMPARE(a.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(a.size(), Vector2i(1, 3));
CORRADE_COMPARE(a.data(), data);
}
void ImageDataTest::constructCompressed() {
auto data = new char[8];
Trade::ImageData2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
Trade::ImageData2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CORRADE_VERIFY(a.isCompressed());
CORRADE_COMPARE(a.compressedFormat(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.compressedFormat(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.size(), Vector2i(4, 4));
CORRADE_COMPARE(a.data(), data);
CORRADE_COMPARE(a.data().size(), 8);
@ -88,48 +88,48 @@ void ImageDataTest::constructCopy() {
void ImageDataTest::constructMove() {
auto data = new char[3];
Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
Trade::ImageData2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
Trade::ImageData2D b(std::move(a));
CORRADE_COMPARE(a.data(), nullptr);
CORRADE_COMPARE(a.size(), Vector2i());
CORRADE_VERIFY(!b.isCompressed());
CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.format(), PixelFormat::Red);
CORRADE_COMPARE(b.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_COMPARE(b.data(), data);
auto data2 = new char[3];
Trade::ImageData2D c(ColorFormat::RGBA, ColorType::UnsignedShort, {2, 6}, data2);
Trade::ImageData2D c(PixelFormat::RGBA, PixelType::UnsignedShort, {2, 6}, data2);
c = std::move(b);
CORRADE_COMPARE(b.data(), data2);
CORRADE_COMPARE(b.size(), Vector2i(2, 6));
CORRADE_VERIFY(!c.isCompressed());
CORRADE_COMPARE(c.format(), ColorFormat::Red);
CORRADE_COMPARE(c.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(c.format(), PixelFormat::Red);
CORRADE_COMPARE(c.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(c.size(), Vector2i(1, 3));
CORRADE_COMPARE(c.data(), data);
}
void ImageDataTest::constructMoveCompressed() {
auto data = new char[8];
Trade::ImageData2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
Trade::ImageData2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
Trade::ImageData2D b{std::move(a)};
CORRADE_COMPARE(a.data(), nullptr);
CORRADE_COMPARE(a.size(), Vector2i());
CORRADE_VERIFY(b.isCompressed());
CORRADE_COMPARE(b.compressedFormat(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.compressedFormat(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.size(), Vector2i(4, 4));
CORRADE_COMPARE(b.data(), data);
CORRADE_COMPARE(b.data().size(), 8);
auto data2 = new char[16];
Trade::ImageData2D c{CompressedColorFormat::RGBAS3tcDxt3, {8, 4}, Containers::Array<char>{data2, 16}};
Trade::ImageData2D c{CompressedPixelFormat::RGBAS3tcDxt3, {8, 4}, Containers::Array<char>{data2, 16}};
c = std::move(b);
CORRADE_COMPARE_AS(b.data(), data2, char*);
@ -137,7 +137,7 @@ void ImageDataTest::constructMoveCompressed() {
CORRADE_COMPARE(b.size(), Vector2i(8, 4));
CORRADE_VERIFY(c.isCompressed());
CORRADE_COMPARE(c.compressedFormat(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(c.compressedFormat(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(c.size(), Vector2i(4, 4));
CORRADE_COMPARE(c.data(), data);
CORRADE_COMPARE(c.data().size(), 8);
@ -145,11 +145,11 @@ void ImageDataTest::constructMoveCompressed() {
void ImageDataTest::toReference() {
auto data = new char[3];
const Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data);
const Trade::ImageData2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data);
ImageView2D b = a;
CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.format(), PixelFormat::Red);
CORRADE_COMPARE(b.type(), PixelType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_COMPARE(b.data(), data);
@ -165,10 +165,10 @@ void ImageDataTest::toReference() {
void ImageDataTest::toReferenceCompressed() {
auto data = new char[8];
const Trade::ImageData2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
const Trade::ImageData2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
CompressedImageView2D b = a;
CORRADE_COMPARE(b.format(), CompressedColorFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(b.size(), Vector2i(4, 4));
CORRADE_COMPARE(b.data(), data);
CORRADE_COMPARE(b.data().size(), 8);
@ -185,7 +185,7 @@ void ImageDataTest::toReferenceCompressed() {
void ImageDataTest::release() {
char data[] = {'b', 'e', 'e', 'r'};
Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 4}, data);
Trade::ImageData2D a(PixelFormat::Red, PixelType::UnsignedByte, {1, 4}, data);
const char* const pointer = a.release().release();
CORRADE_COMPARE(pointer, data);
@ -195,7 +195,7 @@ void ImageDataTest::release() {
void ImageDataTest::releaseCompressed() {
char data[8];
Trade::ImageData2D a{CompressedColorFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
Trade::ImageData2D a{CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, Containers::Array<char>{data, 8}};
const char* const pointer = a.release().release();
CORRADE_COMPARE(pointer, data);

4
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp

@ -29,8 +29,8 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Directory.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Text/GlyphCache.h"
#include "Magnum/Text/AbstractFont.h"
#include "MagnumPlugins/TgaImageConverter/TgaImageConverter.h"
@ -104,7 +104,7 @@ std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter
std::copy(confStr.begin(), confStr.end(), confData.begin());
/* Save cache image */
Image2D image(ColorFormat::Red, ColorType::UnsignedByte);
Image2D image(PixelFormat::Red, PixelType::UnsignedByte);
cache.texture().image(0, image);
auto tgaData = Trade::TgaImageConverter().exportToData(image);

6
src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp

@ -26,8 +26,8 @@
#include <Corrade/Utility/Directory.h>
#include <Corrade/TestSuite/Compare/File.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/Extensions.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Test/AbstractOpenGLTester.h"
#include "Magnum/Text/GlyphCache.h"
@ -117,8 +117,8 @@ void MagnumFontConverterGLTest::exportFont() {
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), Vector2i(256));
CORRADE_COMPARE(image->format(), ColorFormat::Red);
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte);
CORRADE_COMPARE(image->format(), PixelFormat::Red);
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);
}
}}}

16
src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp

@ -29,8 +29,8 @@
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/Directory.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Trade/ImageData.h"
#include "MagnumPlugins/TgaImageConverter/TgaImageConverter.h"
#include "MagnumPlugins/TgaImporter/TgaImporter.h"
@ -56,7 +56,7 @@ namespace {
5, 6, 7, 6, 7, 8
};
const ImageView2D original(ColorFormat::RGB, ColorType::UnsignedByte, {2, 3}, originalData);
const ImageView2D original(PixelFormat::RGB, PixelType::UnsignedByte, {2, 3}, originalData);
}
TgaImageConverterTest::TgaImageConverterTest() {
@ -67,25 +67,25 @@ TgaImageConverterTest::TgaImageConverterTest() {
}
void TgaImageConverterTest::wrongFormat() {
ImageView2D image(ColorFormat::RG, ColorType::UnsignedByte, {}, nullptr);
ImageView2D image(PixelFormat::RG, PixelType::UnsignedByte, {}, nullptr);
std::ostringstream out;
Error::setOutput(&out);
const auto data = TgaImageConverter().exportToData(image);
CORRADE_VERIFY(!data);
CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::exportToData(): unsupported color format ColorFormat::RG\n");
CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::exportToData(): unsupported color format PixelFormat::RG\n");
}
void TgaImageConverterTest::wrongType() {
ImageView2D image(ColorFormat::Red, ColorType::Float, {}, nullptr);
ImageView2D image(PixelFormat::Red, PixelType::Float, {}, nullptr);
std::ostringstream out;
Error::setOutput(&out);
const auto data = TgaImageConverter().exportToData(image);
CORRADE_VERIFY(!data);
CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::exportToData(): unsupported color type ColorType::Float\n");
CORRADE_COMPARE(out.str(), "Trade::TgaImageConverter::exportToData(): unsupported color type PixelType::Float\n");
}
void TgaImageConverterTest::data() {
@ -97,8 +97,8 @@ void TgaImageConverterTest::data() {
CORRADE_VERIFY(converted);
CORRADE_COMPARE(converted->size(), Vector2i(2, 3));
CORRADE_COMPARE(converted->format(), ColorFormat::RGB);
CORRADE_COMPARE(converted->type(), ColorType::UnsignedByte);
CORRADE_COMPARE(converted->format(), PixelFormat::RGB);
CORRADE_COMPARE(converted->type(), PixelType::UnsignedByte);
CORRADE_COMPARE((std::string{converted->data(), 2*3*3}),
(std::string{original.data(), 2*3*3}));
}

24
src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp

@ -31,8 +31,8 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Endianness.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/Image.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Math/Swizzle.h"
#include "Magnum/Math/Vector4.h"
#include "MagnumPlugins/TgaImporter/TgaHeader.h"
@ -46,13 +46,13 @@ TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, st
auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; }
Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& image) const {
if(image.format() != ColorFormat::RGB &&
image.format() != ColorFormat::RGBA
if(image.format() != PixelFormat::RGB &&
image.format() != PixelFormat::RGBA
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
&& image.format() != ColorFormat::Red
&& image.format() != PixelFormat::Red
#endif
#ifdef MAGNUM_TARGET_GLES2
&& image.format() != ColorFormat::Luminance
&& image.format() != PixelFormat::Luminance
#endif
)
{
@ -60,7 +60,7 @@ Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& ima
return nullptr;
}
if(image.type() != ColorType::UnsignedByte) {
if(image.type() != PixelType::UnsignedByte) {
Error() << "Trade::TgaImageConverter::exportToData(): unsupported color type" << image.type();
return nullptr;
}
@ -72,15 +72,15 @@ Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& ima
/* Fill header */
auto header = reinterpret_cast<TgaHeader*>(data.begin());
switch(image.format()) {
case ColorFormat::RGB:
case ColorFormat::RGBA:
case PixelFormat::RGB:
case PixelFormat::RGBA:
header->imageType = 2;
break;
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case ColorFormat::Red:
case PixelFormat::Red:
#endif
#ifdef MAGNUM_TARGET_GLES2
case ColorFormat::Luminance:
case PixelFormat::Luminance:
#endif
header->imageType = 3;
break;
@ -93,11 +93,11 @@ Containers::Array<char> TgaImageConverter::doExportToData(const ImageView2D& ima
/* Fill data */
std::copy(image.data(), image.data()+pixelSize*image.size().product(), data.begin()+sizeof(TgaHeader));
if(image.format() == ColorFormat::RGB) {
if(image.format() == PixelFormat::RGB) {
auto pixels = reinterpret_cast<Math::Vector3<UnsignedByte>*>(data.begin()+sizeof(TgaHeader));
std::transform(pixels, pixels + image.size().product(), pixels,
[](Math::Vector3<UnsignedByte> pixel) { return Math::swizzle<'b', 'g', 'r'>(pixel); });
} else if(image.format() == ColorFormat::RGBA) {
} else if(image.format() == PixelFormat::RGBA) {
auto pixels = reinterpret_cast<Math::Vector4<UnsignedByte>*>(data.begin()+sizeof(TgaHeader));
std::transform(pixels, pixels + image.size().product(), pixels,
[](Math::Vector4<UnsignedByte> pixel) { return Math::swizzle<'b', 'g', 'r', 'a'>(pixel); });

6
src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h

@ -51,9 +51,9 @@ namespace Magnum { namespace Trade {
/**
@brief TGA image converter plugin
Supports images with format @ref ColorFormat::RGB, @ref ColorFormat::RGBA or
@ref ColorFormat::Red (or @ref ColorFormat::Luminance in OpenGL ES 2.0 and
WebGL 1.0) and type @ref ColorType::UnsignedByte.
Supports images with format @ref PixelFormat::RGB, @ref PixelFormat::RGBA or
@ref PixelFormat::Red (or @ref PixelFormat::Luminance in OpenGL ES 2.0 and
WebGL 1.0) and type @ref PixelType::UnsignedByte.
This plugin is built if `WITH_TGAIMAGECONVERTER` is enabled when building
Magnum. To use dynamic plugin, you need to load `TgaImageConverter` plugin

22
src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp

@ -29,7 +29,7 @@
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/Directory.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Trade/ImageData.h"
#include "MagnumPlugins/TgaImporter/TgaImporter.h"
@ -146,9 +146,9 @@ void TgaImporterTest::colorBits24() {
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->format(), ColorFormat::RGB);
CORRADE_COMPARE(image->format(), PixelFormat::RGB);
CORRADE_COMPARE(image->size(), Vector2i(2, 3));
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte);
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(image->data(), Containers::ArrayView<const char>{pixels},
TestSuite::Compare::Container);
}
@ -170,9 +170,9 @@ void TgaImporterTest::colorBits32() {
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->format(), ColorFormat::RGBA);
CORRADE_COMPARE(image->format(), PixelFormat::RGBA);
CORRADE_COMPARE(image->size(), Vector2i(2, 3));
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte);
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(image->data(), Containers::ArrayView<const char>{pixels},
TestSuite::Compare::Container);
}
@ -190,12 +190,12 @@ void TgaImporterTest::grayscaleBits8() {
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
#ifndef MAGNUM_TARGET_GLES2
CORRADE_COMPARE(image->format(), ColorFormat::Red);
CORRADE_COMPARE(image->format(), PixelFormat::Red);
#else
CORRADE_COMPARE(image->format(), ColorFormat::Luminance);
CORRADE_COMPARE(image->format(), PixelFormat::Luminance);
#endif
CORRADE_COMPARE(image->size(), Vector2i(2, 3));
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte);
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(image->data(), Containers::ArrayView<const char>{data}.suffix(18),
TestSuite::Compare::Container);
}
@ -224,12 +224,12 @@ void TgaImporterTest::file() {
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
#ifndef MAGNUM_TARGET_GLES2
CORRADE_COMPARE(image->format(), ColorFormat::Red);
CORRADE_COMPARE(image->format(), PixelFormat::Red);
#else
CORRADE_COMPARE(image->format(), ColorFormat::Luminance);
CORRADE_COMPARE(image->format(), PixelFormat::Luminance);
#endif
CORRADE_COMPARE(image->size(), Vector2i(2, 3));
CORRADE_COMPARE(image->type(), ColorType::UnsignedByte);
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(image->data(), Containers::ArrayView<const char>{data}.suffix(18),
TestSuite::Compare::Container);
}

20
src/MagnumPlugins/TgaImporter/TgaImporter.cpp

@ -31,7 +31,7 @@
#include <Corrade/Utility/Endianness.h>
#include <Corrade/Containers/ArrayView.h>
#include "Magnum/ColorFormat.h"
#include "Magnum/PixelFormat.h"
#include "Magnum/Math/Swizzle.h"
#include "Magnum/Math/Vector4.h"
#include "Magnum/Trade/ImageData.h"
@ -91,7 +91,7 @@ std::optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt) {
header.height = Utility::Endianness::littleEndian(header.height);
/* Image format */
ColorFormat format;
PixelFormat format;
if(header.colorMapType != 0) {
Error() << "Trade::TgaImporter::image2D(): paletted files are not supported";
return std::nullopt;
@ -101,10 +101,10 @@ std::optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt) {
if(header.imageType == 2) {
switch(header.bpp) {
case 24:
format = ColorFormat::RGB;
format = PixelFormat::RGB;
break;
case 32:
format = ColorFormat::RGBA;
format = PixelFormat::RGBA;
break;
default:
Error() << "Trade::TgaImporter::image2D(): unsupported color bits-per-pixel:" << header.bpp;
@ -115,11 +115,11 @@ std::optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt) {
} else if(header.imageType == 3) {
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
format = Context::current() && Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>() ?
ColorFormat::Red : ColorFormat::Luminance;
PixelFormat::Red : PixelFormat::Luminance;
#elif !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
format = ColorFormat::Red;
format = PixelFormat::Red;
#else
format = ColorFormat::Luminance;
format = PixelFormat::Luminance;
#endif
if(header.bpp != 8) {
Error() << "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel:" << header.bpp;
@ -138,17 +138,17 @@ std::optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt) {
Vector2i size(header.width, header.height);
if(format == ColorFormat::RGB) {
if(format == PixelFormat::RGB) {
auto pixels = reinterpret_cast<Math::Vector3<UnsignedByte>*>(data);
std::transform(pixels, pixels + size.product(), pixels,
[](Math::Vector3<UnsignedByte> pixel) { return Math::swizzle<'b', 'g', 'r'>(pixel); });
} else if(format == ColorFormat::RGBA) {
} else if(format == PixelFormat::RGBA) {
auto pixels = reinterpret_cast<Math::Vector4<UnsignedByte>*>(data);
std::transform(pixels, pixels + size.product(), pixels,
[](Math::Vector4<UnsignedByte> pixel) { return Math::swizzle<'b', 'g', 'r', 'a'>(pixel); });
}
return ImageData2D(format, ColorType::UnsignedByte, size, data);
return ImageData2D(format, PixelType::UnsignedByte, size, data);
}
}}

6
src/MagnumPlugins/TgaImporter/TgaImporter.h

@ -62,11 +62,11 @@ of another plugin, you need to request `TgaImporter` component of `Magnum`
package in CMake and link to `${MAGNUM_TGAIMPORTER_LIBRARIES}`. See
@ref building, @ref cmake and @ref plugins for more information.
The images are imported with @ref ColorType::UnsignedByte and @ref ColorFormat::RGB,
@ref ColorFormat::RGBA or @ref ColorFormat::Red, respectively. Grayscale images
The images are imported with @ref PixelType::UnsignedByte and @ref PixelFormat::RGB,
@ref PixelFormat::RGBA or @ref PixelFormat::Red, respectively. Grayscale images
require extension @extension{ARB,texture_rg}. In OpenGL ES 2.0, if
@es_extension{EXT,texture_rg} is not supported and in WebGL 1.0, grayscale
images use @ref ColorFormat::Luminance instead of @ref ColorFormat::Red.
images use @ref PixelFormat::Luminance instead of @ref PixelFormat::Red.
*/
class MAGNUM_TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
public:

Loading…
Cancel
Save