diff --git a/src/AbstractFramebuffer.cpp b/src/AbstractFramebuffer.cpp index 56cf6f77b..2b9043bdb 100644 --- a/src/AbstractFramebuffer.cpp +++ b/src/AbstractFramebuffer.cpp @@ -376,12 +376,12 @@ void AbstractFramebuffer::readBufferImplementationDSA(GLenum buffer) { } #endif -void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, const Vector2i& size, const ImageFormat format, const ImageType type, const std::size_t, GLvoid* const data) { +void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) { glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES3 -void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const ImageFormat format, const ImageType type, const std::size_t dataSize, GLvoid* const data) { +void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) { /** @todo Enable when extension wrangler for ES is available */ #ifndef MAGNUM_TARGET_GLES glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), dataSize, data); diff --git a/src/AbstractFramebuffer.h b/src/AbstractFramebuffer.h index 8235c1e47..4d8fd75d1 100644 --- a/src/AbstractFramebuffer.h +++ b/src/AbstractFramebuffer.h @@ -150,7 +150,7 @@ class MAGNUM_EXPORT AbstractFramebuffer { AbstractFramebuffer& operator=(AbstractFramebuffer&&) = delete; public: - /** @todo `GL_IMPLEMENTATION_COLOR_READ_FORMAT`, `GL_IMPLEMENTATION_COLOR_READ_TYPE`, seems to be depending on currently bound FB (aargh). Also for consistency it might be good to rename ImageFormat and ImageType to `ColorFormat` and `ColorType` (@extension{ARB,ES2_compatibility}). */ + /** @todo `GL_IMPLEMENTATION_COLOR_READ_FORMAT`, `GL_IMPLEMENTATION_COLOR_READ_TYPE`, seems to be depending on currently bound FB (aargh) (@extension{ARB,ES2_compatibility}). */ /** * @brief Max supported viewport size @@ -357,10 +357,10 @@ class MAGNUM_EXPORT AbstractFramebuffer { void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer); #endif - typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ImageFormat, ImageType, std::size_t, GLvoid*); - static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); + typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ColorFormat, ColorType, std::size_t, GLvoid*); + static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); #ifndef MAGNUM_TARGET_GLES3 - static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); #endif static ReadImplementation MAGNUM_LOCAL readImplementation; }; diff --git a/src/AbstractImage.cpp b/src/AbstractImage.cpp index fa5ddcec5..bde23f196 100644 --- a/src/AbstractImage.cpp +++ b/src/AbstractImage.cpp @@ -26,117 +26,117 @@ #include -#include "ImageFormat.h" +#include "ColorFormat.h" namespace Magnum { -std::size_t AbstractImage::pixelSize(ImageFormat format, ImageType type) { +std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) { std::size_t size = 0; switch(type) { - case ImageType::UnsignedByte: + case ColorType::UnsignedByte: #ifndef MAGNUM_TARGET_GLES2 - case ImageType::Byte: + case ColorType::Byte: #endif size = 1; break; - case ImageType::UnsignedShort: + case ColorType::UnsignedShort: #ifndef MAGNUM_TARGET_GLES2 - case ImageType::Short: + case ColorType::Short: #endif - case ImageType::HalfFloat: + case ColorType::HalfFloat: size = 2; break; - case ImageType::UnsignedInt: + case ColorType::UnsignedInt: #ifndef MAGNUM_TARGET_GLES2 - case ImageType::Int: + case ColorType::Int: #endif - case ImageType::Float: + case ColorType::Float: size = 4; break; #ifndef MAGNUM_TARGET_GLES - case ImageType::UnsignedByte332: - case ImageType::UnsignedByte233Rev: + case ColorType::UnsignedByte332: + case ColorType::UnsignedByte233Rev: return 1; #endif - case ImageType::UnsignedShort565: + case ColorType::UnsignedShort565: #ifndef MAGNUM_TARGET_GLES - case ImageType::UnsignedShort565Rev: + case ColorType::UnsignedShort565Rev: #endif - case ImageType::UnsignedShort4444: + case ColorType::UnsignedShort4444: #ifndef MAGNUM_TARGET_GLES3 - case ImageType::UnsignedShort4444Rev: + case ColorType::UnsignedShort4444Rev: #endif - case ImageType::UnsignedShort5551: + case ColorType::UnsignedShort5551: #ifndef MAGNUM_TARGET_GLES3 - case ImageType::UnsignedShort1555Rev: + case ColorType::UnsignedShort1555Rev: #endif return 2; #ifndef MAGNUM_TARGET_GLES - case ImageType::UnsignedInt8888: - case ImageType::UnsignedInt8888Rev: - case ImageType::UnsignedInt1010102: + case ColorType::UnsignedInt8888: + case ColorType::UnsignedInt8888Rev: + case ColorType::UnsignedInt1010102: #endif - case ImageType::UnsignedInt2101010Rev: + case ColorType::UnsignedInt2101010Rev: #ifndef MAGNUM_TARGET_GLES2 - case ImageType::UnsignedInt10F11F11FRev: - case ImageType::UnsignedInt5999Rev: + case ColorType::UnsignedInt10F11F11FRev: + case ColorType::UnsignedInt5999Rev: #endif - case ImageType::UnsignedInt248: + case ColorType::UnsignedInt248: return 4; #ifndef MAGNUM_TARGET_GLES2 - case ImageType::Float32UnsignedInt248Rev: + case ColorType::Float32UnsignedInt248Rev: return 8; #endif } switch(format) { - case ImageFormat::Red: + case ColorFormat::Red: #ifndef MAGNUM_TARGET_GLES2 - case ImageFormat::RedInteger: + case ColorFormat::RedInteger: #endif #ifndef MAGNUM_TARGET_GLES - case ImageFormat::Green: - case ImageFormat::Blue: - case ImageFormat::GreenInteger: - case ImageFormat::BlueInteger: + case ColorFormat::Green: + case ColorFormat::Blue: + case ColorFormat::GreenInteger: + case ColorFormat::BlueInteger: #endif #ifdef MAGNUM_TARGET_GLES2 - case ImageFormat::Luminance: + case ColorFormat::Luminance: #endif return 1*size; - case ImageFormat::RG: + case ColorFormat::RG: #ifndef MAGNUM_TARGET_GLES2 - case ImageFormat::RGInteger: + case ColorFormat::RGInteger: #endif #ifdef MAGNUM_TARGET_GLES2 - case ImageFormat::LuminanceAlpha: + case ColorFormat::LuminanceAlpha: #endif return 2*size; - case ImageFormat::RGB: + case ColorFormat::RGB: #ifndef MAGNUM_TARGET_GLES2 - case ImageFormat::RGBInteger: + case ColorFormat::RGBInteger: #endif #ifndef MAGNUM_TARGET_GLES - case ImageFormat::BGR: - case ImageFormat::BGRInteger: + case ColorFormat::BGR: + case ColorFormat::BGRInteger: #endif return 3*size; - case ImageFormat::RGBA: + case ColorFormat::RGBA: #ifndef MAGNUM_TARGET_GLES2 - case ImageFormat::RGBAInteger: + case ColorFormat::RGBAInteger: #endif #ifndef MAGNUM_TARGET_GLES3 - case ImageFormat::BGRA: + case ColorFormat::BGRA: #endif #ifndef MAGNUM_TARGET_GLES - case ImageFormat::BGRAInteger: + case ColorFormat::BGRAInteger: #endif return 4*size; /* Handled above */ - case ImageFormat::DepthComponent: + case ColorFormat::DepthComponent: #ifndef MAGNUM_TARGET_GLES3 - case ImageFormat::StencilIndex: + case ColorFormat::StencilIndex: #endif - case ImageFormat::DepthStencil: + case ColorFormat::DepthStencil: CORRADE_ASSERT_UNREACHABLE(); } diff --git a/src/AbstractImage.h b/src/AbstractImage.h index 17cfce16f..f8506c399 100644 --- a/src/AbstractImage.h +++ b/src/AbstractImage.h @@ -54,13 +54,13 @@ class MAGNUM_EXPORT AbstractImage { * * @see pixelSize() const */ - static std::size_t pixelSize(ImageFormat format, ImageType type); + static std::size_t pixelSize(ColorFormat format, ColorType type); /** @brief Format of pixel data */ - constexpr ImageFormat format() const { return _format; } + constexpr ColorFormat format() const { return _format; } /** @brief Data type of pixel data */ - constexpr ImageType type() const { return _type; } + constexpr ColorType type() const { return _type; } /** * @brief Pixel size (in bytes) @@ -75,7 +75,7 @@ class MAGNUM_EXPORT AbstractImage { * @param format Format of pixel data * @param type Data type of pixel data */ - constexpr explicit AbstractImage(ImageFormat format, ImageType type): _format(format), _type(type) {} + constexpr explicit AbstractImage(ColorFormat format, ColorType type): _format(format), _type(type) {} ~AbstractImage() = default; @@ -84,8 +84,8 @@ class MAGNUM_EXPORT AbstractImage { #else protected: #endif - ImageFormat _format; - ImageType _type; + ColorFormat _format; + ColorType _type; }; } diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 63a8d3ccb..5881b7c6c 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -26,10 +26,10 @@ #include "Buffer.h" #include "BufferImage.h" +#include "ColorFormat.h" #include "Context.h" #include "Extensions.h" #include "Image.h" -#include "ImageFormat.h" #include "Shader.h" #include "TextureFormat.h" #include "Implementation/State.h" @@ -284,7 +284,7 @@ void AbstractTexture::initializeContextBasedFunctionality(Context& context) { #endif } -ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) { +ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) { switch(internalFormat) { case TextureFormat::Red: #ifndef MAGNUM_TARGET_GLES2 @@ -304,7 +304,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRedRtgc1: case TextureFormat::CompressedSignedRedRgtc1: #endif - return ImageFormat::Red; + return ColorFormat::Red; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R8UI: @@ -313,7 +313,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::R16I: case TextureFormat::R32UI: case TextureFormat::R32I: - return ImageFormat::RedInteger; + return ColorFormat::RedInteger; #endif case TextureFormat::RG: @@ -334,7 +334,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRGRgtc2: case TextureFormat::CompressedSignedRGRgtc2: #endif - return ImageFormat::RG; + return ColorFormat::RG; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RG8UI: @@ -343,7 +343,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::RG16I: case TextureFormat::RG32UI: case TextureFormat::RG32I: - return ImageFormat::RGInteger; + return ColorFormat::RGInteger; #endif case TextureFormat::RGB: @@ -386,7 +386,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRGBBptcUnsignedFloat: case TextureFormat::CompressedRGBBptcSignedFloat: #endif - return ImageFormat::RGB; + return ColorFormat::RGB; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGB8UI: @@ -395,7 +395,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::RGB16I: case TextureFormat::RGB32UI: case TextureFormat::RGB32I: - return ImageFormat::RGBInteger; + return ColorFormat::RGBInteger; #endif case TextureFormat::RGBA: @@ -431,7 +431,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRGBABptcUnorm: case TextureFormat::CompressedSRGBAlphaBptcUnorm: #endif - return ImageFormat::RGBA; + return ColorFormat::RGBA; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGBA8UI: @@ -441,14 +441,14 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::RGBA32UI: case TextureFormat::RGBA32I: case TextureFormat::RGB10A2UI: - return ImageFormat::RGBAInteger; + return ColorFormat::RGBAInteger; #endif #ifdef MAGNUM_TARGET_GLES2 case TextureFormat::Luminance: - return ImageFormat::Luminance; + return ColorFormat::Luminance; case TextureFormat::LuminanceAlpha: - return ImageFormat::LuminanceAlpha; + return ColorFormat::LuminanceAlpha; #endif case TextureFormat::DepthComponent: @@ -460,11 +460,11 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::DepthComponent32F: #endif - return ImageFormat::DepthComponent; + return ColorFormat::DepthComponent; #ifndef MAGNUM_TARGET_GLES case TextureFormat::StencilIndex8: - return ImageFormat::StencilIndex; + return ColorFormat::StencilIndex; #endif case TextureFormat::DepthStencil: @@ -472,13 +472,13 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::Depth32FStencil8: #endif - return ImageFormat::DepthStencil; + return ColorFormat::DepthStencil; } CORRADE_ASSERT_UNREACHABLE(); } -ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) { +ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) { switch(internalFormat) { case TextureFormat::Red: case TextureFormat::RG: @@ -519,7 +519,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::CompressedRGBABptcUnorm: case TextureFormat::CompressedSRGBAlphaBptcUnorm: #endif - return ImageType::UnsignedByte; + return ColorType::UnsignedByte; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R8Snorm: @@ -534,7 +534,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::CompressedSignedRedRgtc1: case TextureFormat::CompressedSignedRGRgtc2: #endif - return ImageType::Byte; + return ColorType::Byte; #endif #ifndef MAGNUM_TARGET_GLES @@ -556,7 +556,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern #ifndef MAGNUM_TARGET_GLES case TextureFormat::RGBA12: /**< @todo really? */ #endif - return ImageType::UnsignedShort; + return ColorType::UnsignedShort; #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES @@ -569,7 +569,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::RG16I: case TextureFormat::RGB16I: case TextureFormat::RGBA16I: - return ImageType::Short; + return ColorType::Short; #endif #ifndef MAGNUM_TARGET_GLES2 @@ -577,19 +577,19 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::RG16F: case TextureFormat::RGB16F: case TextureFormat::RGBA16F: - return ImageType::HalfFloat; + return ColorType::HalfFloat; case TextureFormat::R32UI: case TextureFormat::RG32UI: case TextureFormat::RGB32UI: case TextureFormat::RGBA32UI: - return ImageType::UnsignedInt; + return ColorType::UnsignedInt; case TextureFormat::R32I: case TextureFormat::RG32I: case TextureFormat::RGB32I: case TextureFormat::RGBA32I: - return ImageType::Int; + return ColorType::Int; case TextureFormat::R32F: case TextureFormat::RG32F: @@ -599,24 +599,24 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::CompressedRGBBptcUnsignedFloat: case TextureFormat::CompressedRGBBptcSignedFloat: #endif - return ImageType::Float; + return ColorType::Float; #endif #ifndef MAGNUM_TARGET_GLES case TextureFormat::R3B3G2: - return ImageType::UnsignedByte332; + return ColorType::UnsignedByte332; case TextureFormat::RGB4: - return ImageType::UnsignedShort4444; + return ColorType::UnsignedShort4444; #endif #ifndef MAGNUM_TARGET_GLES case TextureFormat::RGB5: #endif case TextureFormat::RGB5A1: - return ImageType::UnsignedShort5551; + return ColorType::UnsignedShort5551; case TextureFormat::RGB565: - return ImageType::UnsignedShort565; + return ColorType::UnsignedShort565; #ifndef MAGNUM_TARGET_GLES3 case TextureFormat::RGB10: @@ -625,42 +625,42 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGB10A2UI: #endif - return ImageType::UnsignedInt2101010Rev; /**< @todo Rev for all? */ + return ColorType::UnsignedInt2101010Rev; /**< @todo Rev for all? */ #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R11FG11FB10F: - return ImageType::UnsignedInt10F11F11FRev; + return ColorType::UnsignedInt10F11F11FRev; case TextureFormat::RGB9E5: - return ImageType::UnsignedInt5999Rev; + return ColorType::UnsignedInt5999Rev; #endif case TextureFormat::DepthComponent16: - return ImageType::UnsignedShort; + return ColorType::UnsignedShort; case TextureFormat::DepthComponent: case TextureFormat::DepthComponent24: #ifndef MAGNUM_TARGET_GLES3 case TextureFormat::DepthComponent32: #endif - return ImageType::UnsignedInt; + return ColorType::UnsignedInt; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::DepthComponent32F: - return ImageType::Float; + return ColorType::Float; #endif #ifndef MAGNUM_TARGET_GLES case TextureFormat::StencilIndex8: - return ImageType::UnsignedByte; + return ColorType::UnsignedByte; #endif case TextureFormat::DepthStencil: case TextureFormat::Depth24Stencil8: - return ImageType::UnsignedInt248; + return ColorType::UnsignedInt248; #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::Depth32FStencil8: - return ImageType::Float32UnsignedInt248Rev; + return ColorType::Float32UnsignedInt248Rev; #endif } @@ -715,8 +715,8 @@ void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint le void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { CORRADE_INTERNAL_ASSERT(target == GL_TEXTURE_1D); - const ImageFormat format = imageFormatForInternalFormat(internalFormat); - const ImageType type = imageTypeForInternalFormat(internalFormat); + const ColorFormat format = imageFormatForInternalFormat(internalFormat); + const ColorType type = imageTypeForInternalFormat(internalFormat); for(GLsizei level = 0; level != levels; ++level) { (this->*image1DImplementation)(target, level, internalFormat, Math::max(Math::Vector<1, GLsizei>(1), size >> level), format, type, nullptr); @@ -743,8 +743,8 @@ void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, Te #endif void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { - const ImageFormat format = imageFormatForInternalFormat(internalFormat); - const ImageType type = imageTypeForInternalFormat(internalFormat); + const ColorFormat format = imageFormatForInternalFormat(internalFormat); + const ColorType type = imageTypeForInternalFormat(internalFormat); /* Common code for classic types */ #ifndef MAGNUM_TARGET_GLES @@ -802,8 +802,8 @@ void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, Te #endif void AbstractTexture::storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { - const ImageFormat format = imageFormatForInternalFormat(internalFormat); - const ImageType type = imageTypeForInternalFormat(internalFormat); + const ColorFormat format = imageFormatForInternalFormat(internalFormat); + const ColorType type = imageTypeForInternalFormat(internalFormat); /* Common code for classic type */ #ifndef MAGNUM_TARGET_GLES2 @@ -855,16 +855,16 @@ void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, Te #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::getImageImplementationDefault(const GLenum target, const GLint level, const ImageFormat format, const ImageType type, const std::size_t, GLvoid* const data) { +void AbstractTexture::getImageImplementationDefault(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) { bindInternal(); glGetTexImage(target, level, GLenum(format), GLenum(type), data); } -void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const ImageFormat format, const ImageType type, const std::size_t, GLvoid* const data) { +void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) { glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data); } -void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ImageFormat format, const ImageType type, const std::size_t dataSize, GLvoid* const data) { +void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) { #ifndef MAGNUM_TARGET_GLES bindInternal(); glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data); @@ -881,28 +881,28 @@ void AbstractTexture::getImageImplementationRobustness(const GLenum target, cons #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); glTexImage1D(target, level, static_cast(internalFormat), size[0], 0, static_cast(format), static_cast(type), data); } -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast(format), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); /** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -919,34 +919,34 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast(format), static_cast(type), data); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); glTexSubImage1D(target, level, offset[0], size[0], static_cast(format), static_cast(type), data); } -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); /** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -963,7 +963,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast(format), static_cast(type), data); } #endif diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 1fd395ae5..5cac4fb3c 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -393,52 +393,52 @@ class MAGNUM_EXPORT AbstractTexture { static Storage3DImplementation storage3DImplementation; #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*GetImageImplementation)(GLenum, GLint, ImageFormat, ImageType, std::size_t, GLvoid*); - void MAGNUM_LOCAL getImageImplementationDefault(GLenum target, GLint level, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationDSA(GLenum target, GLint level, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); + typedef void(AbstractTexture::*GetImageImplementation)(GLenum, GLint, ColorFormat, ColorType, std::size_t, GLvoid*); + void MAGNUM_LOCAL getImageImplementationDefault(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationDSA(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); static MAGNUM_LOCAL GetImageImplementation getImageImplementation; #endif #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*Image1DImplementation)(GLenum, GLint, TextureFormat, const Math::Vector<1, GLsizei>&, ImageFormat, ImageType, const GLvoid*); - void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); + typedef void(AbstractTexture::*Image1DImplementation)(GLenum, GLint, TextureFormat, const Math::Vector<1, GLsizei>&, ColorFormat, ColorType, const GLvoid*); + void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); static Image1DImplementation image1DImplementation; #endif - typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, TextureFormat, const Vector2i&, ImageFormat, ImageType, const GLvoid*); - void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); + typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, TextureFormat, const Vector2i&, ColorFormat, ColorType, const GLvoid*); + void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif static Image2DImplementation image2DImplementation; - typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, TextureFormat, const Vector3i&, ImageFormat, ImageType, const GLvoid*); - void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); + typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, TextureFormat, const Vector3i&, ColorFormat, ColorType, const GLvoid*); + void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif static Image3DImplementation image3DImplementation; #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*SubImage1DImplementation)(GLenum, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, ImageFormat, ImageType, const GLvoid*); - void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); + typedef void(AbstractTexture::*SubImage1DImplementation)(GLenum, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, ColorFormat, ColorType, const GLvoid*); + void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, 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(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); static SubImage1DImplementation subImage1DImplementation; #endif - typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Vector2i&, const Vector2i&, ImageFormat, ImageType, const GLvoid*); - void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); + typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Vector2i&, const Vector2i&, ColorFormat, ColorType, const GLvoid*); + void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif static SubImage2DImplementation subImage2DImplementation; - typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Vector3i&, const Vector3i&, ImageFormat, ImageType, const GLvoid*); - void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); + typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Vector3i&, const Vector3i&, ColorFormat, ColorType, const GLvoid*); + void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif static SubImage3DImplementation subImage3DImplementation; @@ -458,8 +458,8 @@ class MAGNUM_EXPORT AbstractTexture { void MAGNUM_LOCAL destroy(); void MAGNUM_LOCAL move(); - ImageFormat MAGNUM_LOCAL imageFormatForInternalFormat(TextureFormat internalFormat); - ImageType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat); + ColorFormat MAGNUM_LOCAL imageFormatForInternalFormat(TextureFormat internalFormat); + ColorType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat); GLuint _id; }; diff --git a/src/BufferImage.cpp b/src/BufferImage.cpp index 4de6bbb6c..35edf27d9 100644 --- a/src/BufferImage.cpp +++ b/src/BufferImage.cpp @@ -27,7 +27,7 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES2 -template void BufferImage::setData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, const void* data, Buffer::Usage usage) { +template void BufferImage::setData(const typename DimensionTraits::VectorType& size, ColorFormat format, ColorType type, const void* data, Buffer::Usage usage) { _format = format; _type = type; _size = size; diff --git a/src/BufferImage.h b/src/BufferImage.h index 634a02b76..67577ba7c 100644 --- a/src/BufferImage.h +++ b/src/BufferImage.h @@ -58,7 +58,7 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac * Dimensions and buffer are empty, call setData() to fill the image * with data. */ - explicit BufferImage(ImageFormat format, ImageType type): AbstractImage(format, type) { + explicit BufferImage(ColorFormat format, ColorType type): AbstractImage(format, type) { _buffer.setTargetHint(Buffer::Target::PixelPack); } @@ -81,7 +81,7 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac * * @see Buffer::setData() */ - void setData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, const void* data, Buffer::Usage usage); + void setData(const typename DimensionTraits::VectorType& size, ColorFormat format, ColorType type, const void* data, Buffer::Usage usage); private: Math::Vector _size; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ec246ec3..616650dab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,12 +51,12 @@ set(Magnum_SRCS AbstractTexture.cpp AbstractShaderProgram.cpp Buffer.cpp + ColorFormat.cpp Context.cpp DebugMarker.cpp DefaultFramebuffer.cpp Framebuffer.cpp Image.cpp - ImageFormat.cpp Mesh.cpp MeshView.cpp OpenGL.cpp @@ -107,6 +107,7 @@ set(Magnum_HEADERS Array.h Buffer.h Color.h + ColorFormat.h Context.h CubeMapTexture.h DebugMarker.h diff --git a/src/ImageFormat.cpp b/src/ColorFormat.cpp similarity index 89% rename from src/ImageFormat.cpp rename to src/ColorFormat.cpp index 0d8d1fb88..235e95f16 100644 --- a/src/ImageFormat.cpp +++ b/src/ColorFormat.cpp @@ -22,16 +22,16 @@ DEALINGS IN THE SOFTWARE. */ -#include "ImageFormat.h" +#include "ColorFormat.h" #include namespace Magnum { #ifndef DOXYGEN_GENERATING_OUTPUT -Debug operator<<(Debug debug, ImageFormat value) { +Debug operator<<(Debug debug, const ColorFormat value) { switch(value) { - #define _c(value) case ImageFormat::value: return debug << "ImageFormat::" #value; + #define _c(value) case ColorFormat::value: return debug << "ColorFormat::" #value; _c(Red) #ifndef MAGNUM_TARGET_GLES _c(Green) @@ -74,12 +74,12 @@ Debug operator<<(Debug debug, ImageFormat value) { #undef _c } - return debug << "ImageFormat::(invalid)"; + return debug << "ColorFormat::(invalid)"; } -Debug operator<<(Debug debug, ImageType value) { +Debug operator<<(Debug debug, const ColorType value) { switch(value) { - #define _c(value) case ImageType::value: return debug << "ImageType::" #value; + #define _c(value) case ColorType::value: return debug << "ColorType::" #value; _c(UnsignedByte) #ifndef MAGNUM_TARGET_GLES2 _c(Byte) @@ -127,7 +127,7 @@ Debug operator<<(Debug debug, ImageType value) { #undef _c } - return debug << "ImageType::(invalid)"; + return debug << "ColorType::(invalid)"; } #endif diff --git a/src/ColorFormat.h b/src/ColorFormat.h new file mode 100644 index 000000000..a1150e10f --- /dev/null +++ b/src/ColorFormat.h @@ -0,0 +1,481 @@ +#ifndef Magnum_ColorFormat_h +#define Magnum_ColorFormat_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Enum Magnum::ColorFormat, Magnum::ColorType + */ + +#include "Magnum.h" +#include "OpenGL.h" +#include "magnumVisibility.h" + +namespace Magnum { + +/** +@brief Format of image data + +Note that some formats can be used only for framebuffer reading (using +AbstractFramebuffer::read()) and some only for texture data (using Texture::setImage() +and others). +@see Image, ImageReference, BufferImage, Trade::ImageData +*/ +enum class ColorFormat: GLenum { + /** + * Floating-point red channel. + * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg}. + * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg}. + */ + #ifndef MAGNUM_TARGET_GLES2 + Red = GL_RED, + #else + Red = GL_RED_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Floating-point green channel. + * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::Red" is + * available in OpenGL ES. + */ + Green = GL_GREEN, + + /** + * Floating-point blue channel. + * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::Red" is + * available in OpenGL ES. + */ + Blue = GL_BLUE, + #endif + + #if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * Floating-point luminance channel. The value is used for all RGB + * channels. + * @deprecated Included for compatibility reasons only, use + * @ref Magnum::ColorFormat "ColorFormat::Red" instead. + * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use + * @ref Magnum::ColorFormat "ColorFormat::Red" instead. + */ + Luminance = GL_LUMINANCE, + #endif + + /** + * Floating-point red and green channel. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg}. + * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg}. + */ + #ifndef MAGNUM_TARGET_GLES2 + RG = GL_RG, + #else + RG = GL_RG_EXT, + #endif + + #if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * Floating-point luminance and alpha channel. First value is used for all + * RGB channels, second value is used for alpha channel. + * @deprecated Included for compatibility reasons only, use + * @ref Magnum::ColorFormat "ColorFormat::RG" instead. + * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use + * @ref Magnum::ColorFormat "ColorFormat::RG" instead. + */ + LuminanceAlpha = GL_LUMINANCE_ALPHA, + #endif + + /** + * Floating-point RGB. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + RGB = GL_RGB, + + /** Floating-point RGBA. */ + RGBA = GL_RGBA, + + #ifndef MAGNUM_TARGET_GLES + /** + * Floating-point BGR. + * @requires_gl Only RGB component ordering is available in OpenGL ES. + */ + BGR = GL_BGR, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * Floating-point BGRA. + * @requires_es_extension %Extension @es_extension{EXT,read_format_bgra} + * for framebuffer reading, extension @es_extension{APPLE,texture_format_BGRA8888} + * or @es_extension{EXT,texture_format_BGRA8888} for texture data. + */ + #ifndef MAGNUM_TARGET_GLES + BGRA = GL_BGRA, + #else + BGRA = GL_BGRA_EXT, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Integer red channel. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only floating-point image data are available in OpenGL + * ES 2.0. + */ + RedInteger = GL_RED_INTEGER, + + #ifndef MAGNUM_TARGET_GLES + /** + * Integer green channel. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RedInteger" + * is available in OpenGL ES 3.0, only floating-point image data are + * available in OpenGL ES 2.0. + */ + GreenInteger = GL_GREEN_INTEGER, + + /** + * Integer blue channel. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RedInteger" is + * available in OpenGL ES 3.0, only floating-point image data are + * available in OpenGL ES 2.0. + */ + BlueInteger = GL_BLUE_INTEGER, + #endif + + /** + * Integer red and green channel. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, only floating-point image data + * are available in OpenGL ES 2.0. + */ + RGInteger = GL_RG_INTEGER, + + /** + * Integer RGB. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, only floating-point image data + * are available in OpenGL ES 2.0. + */ + RGBInteger = GL_RGB_INTEGER, + + /** + * Integer RGBA. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only floating-point image data are available in OpenGL + * ES 2.0. + */ + RGBAInteger = GL_RGBA_INTEGER, + + #ifndef MAGNUM_TARGET_GLES + /** + * Integer BGR. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RGBInteger" is + * available in OpenGL ES 3.0, only floating-point image data are + * available in OpenGL ES 2.0. + */ + BGRInteger = GL_BGR_INTEGER, + + /** + * Integer BGRA. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RGBAInteger" is + * available in OpenGL ES 3.0, only floating-point image data are + * available in OpenGL ES 2.0. + */ + BGRAInteger = GL_BGRA_INTEGER, + #endif + #endif + + /** + * Depth component. + * @requires_gles30 For texture data only, extension @es_extension{ANGLE,depth_texture}. + * @requires_es_extension For framebuffer reading only, extension + * @es_extension2{NV,read_depth,GL_NV_read_depth_stencil}. + */ + DepthComponent = GL_DEPTH_COMPONENT, + + #ifndef MAGNUM_TARGET_GLES3 + /** + * Stencil index. + * @requires_gl44 %Extension @extension{ARB,texture_stencil8} for texture + * data, otherwise for framebuffer reading only. + * @requires_es_extension %Extension @es_extension2{NV,read_stencil,GL_NV_read_depth_stencil}, + * for framebuffer reading only. + * @todo Where to get GL_STENCIL_INDEX in ES? + */ + #ifndef MAGNUM_TARGET_GLES + StencilIndex = GL_STENCIL_INDEX, + #else + StencilIndex = 0x1901, + #endif + #endif + + /** + * Depth and stencil. + * @requires_gl30 %Extension @extension{ARB,framebuffer_object} + * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil}. + * @requires_es_extension For framebuffer reading only, extension + * @es_extension2{NV,read_depth_stencil,GL_NV_read_depth_stencil}. + */ + #ifndef MAGNUM_TARGET_GLES2 + DepthStencil = GL_DEPTH_STENCIL + #else + DepthStencil = GL_DEPTH_STENCIL_OES + #endif +}; + +/** +@brief Type of image data + +Note that some formats can be used only for framebuffer reading (using +AbstractFramebuffer::read()) and some only for texture data (using Texture::setImage() +and others). +@see Image, ImageReference, BufferImage, Trade::ImageData +*/ +enum class ColorType: GLenum { + /** Each component unsigned byte. */ + UnsignedByte = GL_UNSIGNED_BYTE, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Each component signed byte. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, only @ref Magnum::ColorType "ColorType::UnsignedByte" + * is available in OpenGL ES 2.0. + */ + Byte = GL_BYTE, + #endif + + /** + * Each component unsigned short. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} + * or @es_extension{ANGLE,depth_texture}. + */ + UnsignedShort = GL_UNSIGNED_SHORT, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Each component signed short. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, only @ref Magnum::ColorType "ColorType::UnsignedShort" + * is available in OpenGL ES 2.0. + */ + Short = GL_SHORT, + #endif + + /** + * Each component unsigned int. + * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. + * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} + * or @es_extension{ANGLE,depth_texture}. + */ + UnsignedInt = GL_UNSIGNED_INT, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Each component signed int. + * @requires_gles30 Only @ref Magnum::ColorType "ColorType::UnsignedInt" + * is available in OpenGL ES 2.0. + */ + Int = GL_INT, + #endif + + /** + * Each component half float. + * @requires_gl30 %Extension @extension{NV,half_float} / @extension{ARB,half_float_pixel} + * @requires_gles30 For texture data only, extension + * @es_extension2{OES,texture_half_float,OES_texture_float}. + */ + #ifndef MAGNUM_TARGET_GLES2 + HalfFloat = GL_HALF_FLOAT, + #else + HalfFloat = GL_HALF_FLOAT_OES, + #endif + + /** + * Each component float. + * @requires_gles30 For texture data only, extension @es_extension{OES,texture_float}. + */ + Float = GL_FLOAT, + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, unsigned byte, red and green component 3bit, blue component 2bit. + * @requires_gl Packed 12bit types are not available in OpenGL ES. + */ + UnsignedByte332 = GL_UNSIGNED_BYTE_3_3_2, + + /** + * BGR, unsigned byte, red and green component 3bit, blue component 2bit. + * @requires_gl Packed 12bit types are not available in OpenGL ES. + */ + UnsignedByte233Rev = GL_UNSIGNED_BYTE_2_3_3_REV, + #endif + + /** + * RGB, unsigned byte, red and blue component 5bit, green 6bit. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + UnsignedShort565 = GL_UNSIGNED_SHORT_5_6_5, + + #ifndef MAGNUM_TARGET_GLES + /** + * BGR, unsigned short, red and blue 5bit, green 6bit. + * @requires_gl Only @ref Magnum::ColorType "ColorType::RGB565" is + * available in OpenGL ES. + */ + UnsignedShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV, + #endif + + /** + * RGBA, unsigned short, each component 4bit. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + UnsignedShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, + + #ifndef MAGNUM_TARGET_GLES3 + /** + * ABGR, unsigned short, each component 4bit. + * @requires_es_extension For framebuffer reading only, extension + * @es_extension{EXT,read_format_bgra}. + */ + #ifndef MAGNUM_TARGET_GLES + UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV, + #else + UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, + #endif + #endif + + /** + * RGBA, unsigned short, each RGB component 5bit, alpha component 1bit. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + UnsignedShort5551 = GL_UNSIGNED_SHORT_5_5_5_1, + + #ifndef MAGNUM_TARGET_GLES3 + /** + * ABGR, unsigned short, each RGB component 5bit, alpha component 1bit. + * @requires_es_extension For framebuffer reading only, extension + * @es_extension{EXT,read_format_bgra}. + */ + #ifndef MAGNUM_TARGET_GLES + UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV, + #else + UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * RGBA, unsigned int, each component 8bit. + * @requires_gl Use @ref Magnum::ColorType "ColorType::UnsignedByte" in + * OpenGL ES instead. + */ + UnsignedInt8888 = GL_UNSIGNED_INT_8_8_8_8, + + /** + * ABGR, unsigned int, each component 8bit. + * @requires_gl Only RGBA component ordering is available in OpenGL ES, see + * @ref Magnum::ColorType "ColorType::UnsignedInt8888" for more + * information. + */ + UnsignedInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV, + + /** + * RGBA, unsigned int, each RGB component 10bit, alpha component 2bit. + * @requires_gl Only @ref Magnum::ColorType "ColorType::UnsignedInt2101010Rev" + * is available in OpenGL ES. + */ + UnsignedInt1010102 = GL_UNSIGNED_INT_10_10_10_2, + #endif + + /** + * ABGR, unsigned int, each RGB component 10bit, alpha component 2bit. + * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. + * @requires_gles30 For texture data only, extension + * @es_extension{EXT,texture_type_2_10_10_10_REV}. + */ + #ifndef MAGNUM_TARGET_GLES2 + UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV, + #else + UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * BGR, unsigned int, red and green 11bit float, blue 10bit float. + * @requires_gl30 %Extension @extension{EXT,packed_float} + * @requires_gles30 Floating-point types are not available in OpenGL ES + * 2.0. + */ + UnsignedInt10F11F11FRev = GL_UNSIGNED_INT_10F_11F_11F_REV, + + /** + * BGR, unsigned int, each component 9bit + 5bit exponent. + * @requires_gl30 %Extension @extension{EXT,texture_shared_exponent} + * @requires_gles30 Only 8bit and 16bit types are available in OpenGL ES + * 2.0. + */ + UnsignedInt5999Rev = GL_UNSIGNED_INT_5_9_9_9_REV, + #endif + + /** + * Unsigned int, depth component 24bit, stencil index 8bit. + * @requires_gl30 %Extension @extension{ARB,framebuffer_object} + * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil}. + */ + #ifndef MAGNUM_TARGET_GLES2 + UnsignedInt248 = GL_UNSIGNED_INT_24_8, + #else + UnsignedInt248 = GL_UNSIGNED_INT_24_8_OES, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Float + unsigned int, depth component 32bit float, 24bit gap, stencil + * index 8bit. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 For texture data only, only @ref Magnum::ColorType "ColorType::UnsignedInt248" + * is available in OpenGL ES 2.0. + */ + Float32UnsignedInt248Rev = GL_FLOAT_32_UNSIGNED_INT_24_8_REV + #endif +}; + +/** @debugoperator{ColorFormat} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, ColorFormat value); + +/** @debugoperator{ColorFormat} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, ColorType value); + +} + +#endif diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 04e94ea27..4505bf0d4 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -54,7 +54,7 @@ See 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({256, 256}, ImageFormat::RGBA, ImageType::UnsignedByte, dataPositiveX); +Image2D positiveX({256, 256}, ColorFormat::RGBA, ColorType::UnsignedByte, dataPositiveX); // ... CubeMapTexture texture; diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index 670473c2f..0f61a1f5c 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -48,7 +48,7 @@ calling setStorage() or by passing properly sized empty Image to setImage(). Example: array with 16 layers of cube map faces, each face consisting of six 64x64 images: @code -Image3D dummy({64, 64, 16*6}, ImageFormat::RGBA, ImageType::UnsignedByte, nullptr); +Image3D dummy({64, 64, 16*6}, ColorFormat::RGBA, ColorType::UnsignedByte, nullptr); CubeMapTextureArray texture; texture.setMagnificationFilter(Sampler::Filter::Linear) @@ -57,7 +57,7 @@ texture.setMagnificationFilter(Sampler::Filter::Linear) for(std::size_t i = 0; i != 16; ++i) { void* dataPositiveX = ...; - Image2D imagePositiveX({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, imagePositiveX); + Image2D imagePositiveX({64, 64}, ColorFormat::RGBA, ColorType::UnsignedByte, imagePositiveX); // ... texture.setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX); texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); diff --git a/src/Image.cpp b/src/Image.cpp index 312fbfe4f..2d83f8c51 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -26,7 +26,7 @@ namespace Magnum { -template void Image::setData(ImageFormat format, ImageType type, const typename DimensionTraits::VectorType& size, void* data) { +template void Image::setData(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data) { delete[] _data; _format = format; _type = type; diff --git a/src/Image.h b/src/Image.h index cbb420d4b..6c171af4e 100644 --- a/src/Image.h +++ b/src/Image.h @@ -53,7 +53,7 @@ template class Image: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - explicit Image(ImageFormat format, ImageType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + explicit Image(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -63,7 +63,7 @@ template class Image: public AbstractImage { * Dimensions and data pointer are set to zero, call setData() to fill * the image with data. */ - explicit Image(ImageFormat format, ImageType type): AbstractImage(format, type), _data(nullptr) {} + explicit Image(ColorFormat format, ColorType type): AbstractImage(format, type), _data(nullptr) {} /** @brief Copying is not allowed */ Image(const Image&& other) = delete; @@ -104,7 +104,7 @@ template class Image: public AbstractImage { * Deletes previous data and replaces them with new. Note that the * data are not copied, but they are deleted on destruction. */ - void setData(ImageFormat format, ImageType type, const typename DimensionTraits::VectorType& size, void* data); + void setData(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data); private: Math::Vector _size; diff --git a/src/ImageFormat.h b/src/ImageFormat.h index 7e88cc6a1..803b6372c 100644 --- a/src/ImageFormat.h +++ b/src/ImageFormat.h @@ -25,456 +25,25 @@ */ /** @file - * @brief Enum Magnum::ImageFormat, Magnum::ImageType + * @brief Enum @ref Magnum::ImageFormat, @ref Magnum::ImageType + * @deprecated Use @ref ColorFormat.h instead. */ -#include "Magnum.h" -#include "OpenGL.h" -#include "magnumVisibility.h" +#include "ColorFormat.h" namespace Magnum { /** -@brief Format of image data - -Note that some formats can be used only for framebuffer reading (using -AbstractFramebuffer::read()) and some only for texture data (using Texture::setImage() -and others). -@see Image, ImageReference, BufferImage, Trade::ImageData +@copybrief ColorFormat +@deprecated Use @ref ColorFormat instead. */ -enum class ImageFormat: GLenum { - /** - * Floating-point red channel. - * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg}. - * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg}. - */ - #ifndef MAGNUM_TARGET_GLES2 - Red = GL_RED, - #else - Red = GL_RED_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Floating-point green channel. - * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::Red" is - * available in OpenGL ES. - */ - Green = GL_GREEN, - - /** - * Floating-point blue channel. - * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::Red" is - * available in OpenGL ES. - */ - Blue = GL_BLUE, - #endif - - #if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT) - /** - * Floating-point luminance channel. The value is used for all RGB - * channels. - * @deprecated Included for compatibility reasons only, use - * @ref Magnum::ImageFormat "ImageFormat::Red" instead. - * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use - * @ref Magnum::ImageFormat "ImageFormat::Red" instead. - */ - Luminance = GL_LUMINANCE, - #endif - - /** - * Floating-point red and green channel. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} - * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg}. - * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg}. - */ - #ifndef MAGNUM_TARGET_GLES2 - RG = GL_RG, - #else - RG = GL_RG_EXT, - #endif - - #if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT) - /** - * Floating-point luminance and alpha channel. First value is used for all - * RGB channels, second value is used for alpha channel. - * @deprecated Included for compatibility reasons only, use - * @ref Magnum::ImageFormat "ImageFormat::RG" instead. - * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use - * @ref Magnum::ImageFormat "ImageFormat::RG" instead. - */ - LuminanceAlpha = GL_LUMINANCE_ALPHA, - #endif - - /** - * Floating-point RGB. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - */ - RGB = GL_RGB, - - /** Floating-point RGBA. */ - RGBA = GL_RGBA, - - #ifndef MAGNUM_TARGET_GLES - /** - * Floating-point BGR. - * @requires_gl Only RGB component ordering is available in OpenGL ES. - */ - BGR = GL_BGR, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * Floating-point BGRA. - * @requires_es_extension %Extension @es_extension{EXT,read_format_bgra} - * for framebuffer reading, extension @es_extension{APPLE,texture_format_BGRA8888} - * or @es_extension{EXT,texture_format_BGRA8888} for texture data. - */ - #ifndef MAGNUM_TARGET_GLES - BGRA = GL_BGRA, - #else - BGRA = GL_BGRA_EXT, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Integer red channel. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only floating-point image data are available in OpenGL - * ES 2.0. - */ - RedInteger = GL_RED_INTEGER, - - #ifndef MAGNUM_TARGET_GLES - /** - * Integer green channel. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::RedInteger" - * is available in OpenGL ES 3.0, only floating-point image data are - * available in OpenGL ES 2.0. - */ - GreenInteger = GL_GREEN_INTEGER, - - /** - * Integer blue channel. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::RedInteger" is - * available in OpenGL ES 3.0, only floating-point image data are - * available in OpenGL ES 2.0. - */ - BlueInteger = GL_BLUE_INTEGER, - #endif - - /** - * Integer red and green channel. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - * @requires_gles30 For texture data only, only floating-point image data - * are available in OpenGL ES 2.0. - */ - RGInteger = GL_RG_INTEGER, - - /** - * Integer RGB. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - * @requires_gles30 For texture data only, only floating-point image data - * are available in OpenGL ES 2.0. - */ - RGBInteger = GL_RGB_INTEGER, - - /** - * Integer RGBA. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only floating-point image data are available in OpenGL - * ES 2.0. - */ - RGBAInteger = GL_RGBA_INTEGER, - - #ifndef MAGNUM_TARGET_GLES - /** - * Integer BGR. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::RGBInteger" is - * available in OpenGL ES 3.0, only floating-point image data are - * available in OpenGL ES 2.0. - */ - BGRInteger = GL_BGR_INTEGER, - - /** - * Integer BGRA. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::RGBAInteger" is - * available in OpenGL ES 3.0, only floating-point image data are - * available in OpenGL ES 2.0. - */ - BGRAInteger = GL_BGRA_INTEGER, - #endif - #endif - - /** - * Depth component. - * @requires_gles30 For texture data only, extension @es_extension{ANGLE,depth_texture}. - * @requires_es_extension For framebuffer reading only, extension - * @es_extension2{NV,read_depth,GL_NV_read_depth_stencil}. - */ - DepthComponent = GL_DEPTH_COMPONENT, - - #ifndef MAGNUM_TARGET_GLES3 - /** - * Stencil index. - * @requires_gl44 %Extension @extension{ARB,texture_stencil8} for texture - * data, otherwise for framebuffer reading only. - * @requires_es_extension %Extension @es_extension2{NV,read_stencil,GL_NV_read_depth_stencil}, - * for framebuffer reading only. - * @todo Where to get GL_STENCIL_INDEX in ES? - */ - #ifndef MAGNUM_TARGET_GLES - StencilIndex = GL_STENCIL_INDEX, - #else - StencilIndex = 0x1901, - #endif - #endif - - /** - * Depth and stencil. - * @requires_gl30 %Extension @extension{ARB,framebuffer_object} - * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil}. - * @requires_es_extension For framebuffer reading only, extension - * @es_extension2{NV,read_depth_stencil,GL_NV_read_depth_stencil}. - */ - #ifndef MAGNUM_TARGET_GLES2 - DepthStencil = GL_DEPTH_STENCIL - #else - DepthStencil = GL_DEPTH_STENCIL_OES - #endif -}; +typedef ColorFormat ImageFormat; /** -@brief Type of image data - -Note that some formats can be used only for framebuffer reading (using -AbstractFramebuffer::read()) and some only for texture data (using Texture::setImage() -and others). -@see Image, ImageReference, BufferImage, Trade::ImageData +@copybrief ColorType +@deprecated Use @ref ColorType instead. */ -enum class ImageType: GLenum { - /** Each component unsigned byte. */ - UnsignedByte = GL_UNSIGNED_BYTE, - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Each component signed byte. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - * @requires_gles30 For texture data only, only @ref Magnum::ImageType "ImageType::UnsignedByte" - * is available in OpenGL ES 2.0. - */ - Byte = GL_BYTE, - #endif - - /** - * Each component unsigned short. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} - * or @es_extension{ANGLE,depth_texture}. - */ - UnsignedShort = GL_UNSIGNED_SHORT, - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Each component signed short. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - * @requires_gles30 For texture data only, only @ref Magnum::ImageType "ImageType::UnsignedShort" - * is available in OpenGL ES 2.0. - */ - Short = GL_SHORT, - #endif - - /** - * Each component unsigned int. - * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. - * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} - * or @es_extension{ANGLE,depth_texture}. - */ - UnsignedInt = GL_UNSIGNED_INT, - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Each component signed int. - * @requires_gles30 Only @ref Magnum::ImageType "ImageType::UnsignedInt" - * is available in OpenGL ES 2.0. - */ - Int = GL_INT, - #endif - - /** - * Each component half float. - * @requires_gl30 %Extension @extension{NV,half_float} / @extension{ARB,half_float_pixel} - * @requires_gles30 For texture data only, extension - * @es_extension2{OES,texture_half_float,OES_texture_float}. - */ - #ifndef MAGNUM_TARGET_GLES2 - HalfFloat = GL_HALF_FLOAT, - #else - HalfFloat = GL_HALF_FLOAT_OES, - #endif - - /** - * Each component float. - * @requires_gles30 For texture data only, extension @es_extension{OES,texture_float}. - */ - Float = GL_FLOAT, - - #ifndef MAGNUM_TARGET_GLES - /** - * RGB, unsigned byte, red and green component 3bit, blue component 2bit. - * @requires_gl Packed 12bit types are not available in OpenGL ES. - */ - UnsignedByte332 = GL_UNSIGNED_BYTE_3_3_2, - - /** - * BGR, unsigned byte, red and green component 3bit, blue component 2bit. - * @requires_gl Packed 12bit types are not available in OpenGL ES. - */ - UnsignedByte233Rev = GL_UNSIGNED_BYTE_2_3_3_REV, - #endif - - /** - * RGB, unsigned byte, red and blue component 5bit, green 6bit. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - */ - UnsignedShort565 = GL_UNSIGNED_SHORT_5_6_5, - - #ifndef MAGNUM_TARGET_GLES - /** - * BGR, unsigned short, red and blue 5bit, green 6bit. - * @requires_gl Only @ref Magnum::ImageType "ImageType::RGB565" is - * available in OpenGL ES. - */ - UnsignedShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV, - #endif - - /** - * RGBA, unsigned short, each component 4bit. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - */ - UnsignedShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, - - #ifndef MAGNUM_TARGET_GLES3 - /** - * ABGR, unsigned short, each component 4bit. - * @requires_es_extension For framebuffer reading only, extension - * @es_extension{EXT,read_format_bgra}. - */ - #ifndef MAGNUM_TARGET_GLES - UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV, - #else - UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, - #endif - #endif - - /** - * RGBA, unsigned short, each RGB component 5bit, alpha component 1bit. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. - */ - UnsignedShort5551 = GL_UNSIGNED_SHORT_5_5_5_1, - - #ifndef MAGNUM_TARGET_GLES3 - /** - * ABGR, unsigned short, each RGB component 5bit, alpha component 1bit. - * @requires_es_extension For framebuffer reading only, extension - * @es_extension{EXT,read_format_bgra}. - */ - #ifndef MAGNUM_TARGET_GLES - UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV, - #else - UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * RGBA, unsigned int, each component 8bit. - * @requires_gl Use @ref Magnum::ImageType "ImageType::UnsignedByte" in - * OpenGL ES instead. - */ - UnsignedInt8888 = GL_UNSIGNED_INT_8_8_8_8, - - /** - * ABGR, unsigned int, each component 8bit. - * @requires_gl Only RGBA component ordering is available in OpenGL ES, see - * @ref Magnum::ImageType "ImageType::UnsignedInt8888" for more - * information. - */ - UnsignedInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV, - - /** - * RGBA, unsigned int, each RGB component 10bit, alpha component 2bit. - * @requires_gl Only @ref Magnum::ImageType "ImageType::UnsignedInt2101010Rev" - * is available in OpenGL ES. - */ - UnsignedInt1010102 = GL_UNSIGNED_INT_10_10_10_2, - #endif - - /** - * ABGR, unsigned int, each RGB component 10bit, alpha component 2bit. - * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. - * @requires_gles30 For texture data only, extension - * @es_extension{EXT,texture_type_2_10_10_10_REV}. - */ - #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV, - #else - UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * BGR, unsigned int, red and green 11bit float, blue 10bit float. - * @requires_gl30 %Extension @extension{EXT,packed_float} - * @requires_gles30 Floating-point types are not available in OpenGL ES - * 2.0. - */ - UnsignedInt10F11F11FRev = GL_UNSIGNED_INT_10F_11F_11F_REV, - - /** - * BGR, unsigned int, each component 9bit + 5bit exponent. - * @requires_gl30 %Extension @extension{EXT,texture_shared_exponent} - * @requires_gles30 Only 8bit and 16bit types are available in OpenGL ES - * 2.0. - */ - UnsignedInt5999Rev = GL_UNSIGNED_INT_5_9_9_9_REV, - #endif - - /** - * Unsigned int, depth component 24bit, stencil index 8bit. - * @requires_gl30 %Extension @extension{ARB,framebuffer_object} - * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil}. - */ - #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt248 = GL_UNSIGNED_INT_24_8, - #else - UnsignedInt248 = GL_UNSIGNED_INT_24_8_OES, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Float + unsigned int, depth component 32bit float, 24bit gap, stencil - * index 8bit. - * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 For texture data only, only @ref Magnum::ImageType "ImageType::UnsignedInt248" - * is available in OpenGL ES 2.0. - */ - Float32UnsignedInt248Rev = GL_FLOAT_32_UNSIGNED_INT_24_8_REV - #endif -}; - -/** @debugoperator{ImageFormat} */ -Debug MAGNUM_EXPORT operator<<(Debug debug, ImageFormat value); - -/** @debugoperator{ImageFormat} */ -Debug MAGNUM_EXPORT operator<<(Debug debug, ImageType value); +typedef ColorType ImageType; } diff --git a/src/ImageReference.h b/src/ImageReference.h index 8262a80da..1366bc2bc 100644 --- a/src/ImageReference.h +++ b/src/ImageReference.h @@ -63,7 +63,7 @@ template class ImageReference: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - constexpr explicit ImageReference(ImageFormat format, ImageType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -74,7 +74,7 @@ template class ImageReference: public AbstractImage { * Data pointer is set to zero, call setData() to fill the image with * data. */ - constexpr explicit ImageReference(ImageFormat format, ImageType type, const typename DimensionTraits::VectorType& size): AbstractImage(format, type), _size(size), _data(nullptr) {} + constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size): AbstractImage(format, type), _size(size), _data(nullptr) {} /** @brief %Image size */ constexpr typename DimensionTraits::VectorType size() const { return _size; } diff --git a/src/Magnum.h b/src/Magnum.h index 7b982e0ad..cf8ec73e1 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -347,6 +347,12 @@ template class BasicColor4; typedef BasicColor3 Color3; typedef BasicColor4 Color4; +enum class ColorFormat: GLenum; +enum class ColorType: GLenum; +/** @todo Remove this when dropping backward compatibility */ +typedef ColorFormat ImageFormat; +typedef ColorType ColorType; + enum class Version: Int; class Context; class CubeMapTexture; @@ -367,9 +373,6 @@ typedef Image<1> Image1D; typedef Image<2> Image2D; typedef Image<3> Image3D; -enum class ImageFormat: GLenum; -enum class ImageType: GLenum; - template class ImageReference; typedef ImageReference<1> ImageReference1D; typedef ImageReference<2> ImageReference2D; diff --git a/src/Test/AbstractImageTest.cpp b/src/Test/AbstractImageTest.cpp index 73b2b7239..2b4e23916 100644 --- a/src/Test/AbstractImageTest.cpp +++ b/src/Test/AbstractImageTest.cpp @@ -26,7 +26,7 @@ #include #include "AbstractImage.h" -#include "ImageFormat.h" +#include "ColorFormat.h" namespace Magnum { namespace Test { @@ -45,14 +45,14 @@ AbstractImageTest::AbstractImageTest() { void AbstractImageTest::debugFormat() { std::ostringstream o; - Debug(&o) << ImageFormat::RGBA; - CORRADE_COMPARE(o.str(), "ImageFormat::RGBA\n"); + Debug(&o) << ColorFormat::RGBA; + CORRADE_COMPARE(o.str(), "ColorFormat::RGBA\n"); } void AbstractImageTest::debugType() { std::ostringstream o; - Debug(&o) << ImageType::UnsignedShort5551; - CORRADE_COMPARE(o.str(), "ImageType::UnsignedShort5551\n"); + Debug(&o) << ColorType::UnsignedShort5551; + CORRADE_COMPARE(o.str(), "ColorType::UnsignedShort5551\n"); } }} diff --git a/src/Test/ImageTest.cpp b/src/Test/ImageTest.cpp index d16f3a578..6948f9c8d 100644 --- a/src/Test/ImageTest.cpp +++ b/src/Test/ImageTest.cpp @@ -24,8 +24,8 @@ #include +#include "ColorFormat.h" #include "Image.h" -#include "ImageFormat.h" namespace Magnum { namespace Test { @@ -46,36 +46,36 @@ ImageTest::ImageTest() { void ImageTest::moveConstructor() { unsigned char* data = new unsigned char[3]; - Image2D a(ImageFormat::Red, ImageType::UnsignedByte, {1, 3}, data); + Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); Image2D b(std::move(a)); CORRADE_VERIFY(!a.data()); - CORRADE_COMPARE(b.format(), ImageFormat::Red); - CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); + CORRADE_COMPARE(b.format(), ColorFormat::Red); + CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_VERIFY(b.data() == data); } void ImageTest::moveAssignment() { unsigned char* data = new unsigned char[3]; - Image2D a(ImageFormat::Red, ImageType::UnsignedByte, {1, 3}, data); + Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); - Image2D b(ImageFormat::Red, ImageType::UnsignedByte); + Image2D b(ColorFormat::Red, ColorType::UnsignedByte); b = std::move(a); CORRADE_VERIFY(!a.data()); - CORRADE_COMPARE(b.format(), ImageFormat::Red); - CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); + CORRADE_COMPARE(b.format(), ColorFormat::Red); + CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_VERIFY(b.data() == data); } void ImageTest::toReference() { unsigned char* data = new unsigned char[3]; - Image2D a(ImageFormat::Red, ImageType::UnsignedByte, {1, 3}, data); + Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); ImageReference2D b = a; - CORRADE_COMPARE(b.format(), ImageFormat::Red); - CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); + CORRADE_COMPARE(b.format(), ColorFormat::Red); + CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_VERIFY(b.data() == data); } diff --git a/src/Text/DistanceFieldGlyphCache.cpp b/src/Text/DistanceFieldGlyphCache.cpp index 5b2eab84c..0e88dcc1f 100644 --- a/src/Text/DistanceFieldGlyphCache.cpp +++ b/src/Text/DistanceFieldGlyphCache.cpp @@ -24,10 +24,10 @@ #include "DistanceFieldGlyphCache.h" -#include "Extensions.h" #ifndef CORRADE_NO_ASSERT -#include "ImageFormat.h" +#include "ColorFormat.h" #endif +#include "Extensions.h" #include "ImageReference.h" #include "TextureFormat.h" #include "TextureTools/DistanceField.h" @@ -58,18 +58,18 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) { #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) const TextureFormat internalFormat = TextureFormat::R8; - CORRADE_ASSERT(image.format() == ImageFormat::Red, - "Text::DistanceFieldGlyphCache::setImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); + CORRADE_ASSERT(image.format() == ColorFormat::Red, + "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); #else TextureFormat internalFormat; if(Context::current()->isExtensionSupported()) { internalFormat = TextureFormat::Red; - CORRADE_ASSERT(image.format() == ImageFormat::Red, - "Text::DistanceFieldGlyphCache::setImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); + CORRADE_ASSERT(image.format() == ColorFormat::Red, + "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); } else { internalFormat = TextureFormat::Luminance; - CORRADE_ASSERT(image.format() == ImageFormat::Luminance, - "Text::DistanceFieldGlyphCache::setImage(): expected" << ImageFormat::Luminance << "but got" << image.format(), ); + CORRADE_ASSERT(image.format() == ColorFormat::Luminance, + "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Luminance << "but got" << image.format(), ); } #endif @@ -85,16 +85,16 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageRefere void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageReference2D& image) { #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) - CORRADE_ASSERT(image.format() == ImageFormat::Red, - "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); + CORRADE_ASSERT(image.format() == ColorFormat::Red, + "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); #else if(Context::current()->isExtensionSupported()) - CORRADE_ASSERT(image.format() == ImageFormat::Red, - "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); + CORRADE_ASSERT(image.format() == ColorFormat::Red, + "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); /* Luminance is not renderable in most cases */ - else CORRADE_ASSERT(image.format() == ImageFormat::RGB, - "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::RGB << "but got" << image.format(), ); + else CORRADE_ASSERT(image.format() == ColorFormat::RGB, + "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::RGB << "but got" << image.format(), ); #endif texture().setSubImage(0, offset, image); diff --git a/src/Texture.h b/src/Texture.h index b843090b4..615f8665e 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -46,7 +46,7 @@ data from e.g. Image. Example configuration of high quality texture with trilinear anisotropic filtering, i.e. the best you can ask for: @code void* data; -Image2D image({4096, 4096}, ImageFormat::RGBA, ImageType::UnsignedByte, data); +Image2D image({4096, 4096}, ColorFormat::RGBA, ColorType::UnsignedByte, data); Texture2D texture; texture.setMagnificationFilter(Sampler::Filter::Linear) @@ -89,7 +89,7 @@ texture.setMagnificationFilter(Sampler::Filter::Linear) for(std::size_t i = 0; i != 16; ++i) { void* data = ...; - Image2D image({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, image); + Image2D image({64, 64}, ColorFormat::RGBA, ColorType::UnsignedByte, image); texture.setSubImage(0, Vector3i::zAxis(i), image); } diff --git a/src/TextureTools/distance-field.cpp b/src/TextureTools/distance-field.cpp index 8b1b5d9b4..297d15d28 100644 --- a/src/TextureTools/distance-field.cpp +++ b/src/TextureTools/distance-field.cpp @@ -26,8 +26,8 @@ #include #include "Math/Geometry/Rectangle.h" +#include "ColorFormat.h" #include "Image.h" -#include "ImageFormat.h" #include "Renderer.h" #include "Texture.h" #include "TextureFormat.h" @@ -90,7 +90,7 @@ int DistanceFieldConverter::exec() { return 1; } - if(image->format() != ImageFormat::Red) { + if(image->format() != ColorFormat::Red) { Error() << "Unsupported image format" << image->format(); return 1; } @@ -113,7 +113,7 @@ int DistanceFieldConverter::exec() { TextureTools::distanceField(input, output, {{}, args.value("output-size")}, args.value("radius"), image->size()); /* Save image */ - Image2D result(ImageFormat::Red, ImageType::UnsignedByte); + Image2D result(ColorFormat::Red, ColorType::UnsignedByte); output.image(0, result); if(!converter->exportToFile(result, args.value("output"))) { Error() << "Cannot save file" << args.value("output"); diff --git a/src/Trade/ImageData.h b/src/Trade/ImageData.h index cdf9e1552..098461302 100644 --- a/src/Trade/ImageData.h +++ b/src/Trade/ImageData.h @@ -53,7 +53,7 @@ template class ImageData: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - explicit ImageData(ImageFormat format, ImageType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + explicit ImageData(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** @brief Copying is not allowed */ ImageData(const ImageData&& other) = delete; diff --git a/src/Trade/Test/AbstractImageConverterTest.cpp b/src/Trade/Test/AbstractImageConverterTest.cpp index e03d441d9..fa0c5616b 100644 --- a/src/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Trade/Test/AbstractImageConverterTest.cpp @@ -27,7 +27,7 @@ #include #include -#include "ImageFormat.h" +#include "ColorFormat.h" #include "ImageReference.h" #include "Trade/AbstractImageConverter.h" @@ -64,7 +64,7 @@ void AbstractImageConverterTest::exportToFile() { /* doExportToFile() should call doExportToData() */ DataExporter exporter; - ImageReference2D image(ImageFormat::RGBA, ImageType::UnsignedByte, {0xfe, 0xed}, nullptr); + ImageReference2D image(ColorFormat::RGBA, ColorType::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); diff --git a/src/Trade/Test/ImageDataTest.cpp b/src/Trade/Test/ImageDataTest.cpp index 76c836b1e..bf1b9bb41 100644 --- a/src/Trade/Test/ImageDataTest.cpp +++ b/src/Trade/Test/ImageDataTest.cpp @@ -24,7 +24,7 @@ #include -#include "ImageFormat.h" +#include "ColorFormat.h" #include "Trade/ImageData.h" namespace Magnum { namespace Trade { namespace Test { @@ -46,36 +46,36 @@ ImageDataTest::ImageDataTest() { void ImageDataTest::moveConstructor() { unsigned char* data = new unsigned char[3]; - Trade::ImageData2D a(ImageFormat::Red, ImageType::UnsignedByte, {1, 3}, data); + Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); Trade::ImageData2D b(std::move(a)); CORRADE_VERIFY(!a.data()); - CORRADE_COMPARE(b.format(), ImageFormat::Red); - CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); + CORRADE_COMPARE(b.format(), ColorFormat::Red); + CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_VERIFY(b.data() == data); } void ImageDataTest::moveAssignment() { unsigned char* data = new unsigned char[3]; - Trade::ImageData2D a(ImageFormat::Red, ImageType::UnsignedByte, {1, 3}, data); + Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); - Trade::ImageData2D b(ImageFormat::Red, ImageType::UnsignedByte, {}, nullptr); + Trade::ImageData2D b(ColorFormat::Red, ColorType::UnsignedByte, {}, nullptr); b = std::move(a); CORRADE_VERIFY(!a.data()); - CORRADE_COMPARE(b.format(), ImageFormat::Red); - CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); + CORRADE_COMPARE(b.format(), ColorFormat::Red); + CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_VERIFY(b.data() == data); } void ImageDataTest::toReference() { unsigned char* data = new unsigned char[3]; - Trade::ImageData2D a(ImageFormat::Red, ImageType::UnsignedByte, {1, 3}, data); + Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); ImageReference2D b = a; - CORRADE_COMPARE(b.format(), ImageFormat::Red); - CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); + CORRADE_COMPARE(b.format(), ColorFormat::Red); + CORRADE_COMPARE(b.type(), ColorType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.data(), data); }