diff --git a/src/Magnum/ColorFormat.cpp b/src/Magnum/ColorFormat.cpp index 0c7a70b7b..007161c21 100644 --- a/src/Magnum/ColorFormat.cpp +++ b/src/Magnum/ColorFormat.cpp @@ -136,6 +136,29 @@ Debug operator<<(Debug debug, const ColorType value) { return debug << "ColorType::(invalid)"; } + +Debug operator<<(Debug debug, const CompressedColorFormat value) { + switch(value) { + #define _c(value) case CompressedColorFormat::value: return debug << "CompressedColorFormat::" #value; + #ifndef MAGNUM_TARGET_GLES + _c(Red) + _c(RG) + _c(RGB) + _c(RGBA) + _c(RedRgtc1) + _c(RGRgtc2) + _c(SignedRedRgtc1) + _c(SignedRGRgtc2) + _c(RGBBptcUnsignedFloat) + _c(RGBBptcSignedFloat) + _c(RGBABptcUnorm) + _c(SRGBAlphaBptcUnorm) + #endif + #undef _c + } + + return debug << "CompressedColorFormat::(invalid)"; +} #endif } diff --git a/src/Magnum/ColorFormat.h b/src/Magnum/ColorFormat.h index 216d30b90..4daa043ed 100644 --- a/src/Magnum/ColorFormat.h +++ b/src/Magnum/ColorFormat.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Enum @ref Magnum::ColorFormat, @ref Magnum::ColorType + * @brief Enum @ref Magnum::ColorFormat, @ref Magnum::ColorType, @ref Magnum::CompressedColorFormat */ #include "Magnum/Magnum.h" @@ -554,12 +554,121 @@ enum class ColorType: GLenum { #endif }; +/** +@brief Format of compressed image data + +Equivalent to `Compressed*` values of @ref TextureFormat enum. + +@see @ref CompressedImage, @ref CompressedImageView, @ref CompressedBufferImage, + @ref Trade::ImageData +*/ +enum class CompressedColorFormat: GLenum { + #ifndef MAGNUM_TARGET_GLES + /** + * Compressed red channel, normalized unsigned. + * @requires_gl30 Extension @extension{ARB,texture_rg} + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. + */ + Red = GL_COMPRESSED_RED, + + /** + * Compressed red and green channel, normalized unsigned. + * @requires_gl30 Extension @extension{ARB,texture_rg} + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. + */ + RG = GL_COMPRESSED_RG, + + /** + * Compressed RGB, normalized unsigned. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. + */ + RGB = GL_COMPRESSED_RGB, + + /** + * Compressed RGBA, normalized unsigned. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. + */ + RGBA = GL_COMPRESSED_RGBA, + + /** + * RGTC compressed red channel, normalized unsigned. + * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. + */ + RedRgtc1 = GL_COMPRESSED_RED_RGTC1, + + /** + * RGTC compressed red and green channel, normalized unsigned. + * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. + */ + RGRgtc2 = GL_COMPRESSED_RG_RGTC2, + + /** + * RGTC compressed red channel, normalized signed. + * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. + */ + SignedRedRgtc1 = GL_COMPRESSED_SIGNED_RED_RGTC1, + + /** + * RGTC compressed red and green channel, normalized signed. + * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. + */ + SignedRGRgtc2 = GL_COMPRESSED_SIGNED_RG_RGTC2, + + /** + * BPTC compressed RGB, unsigned float. + * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. + */ + RGBBptcUnsignedFloat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, + + /** + * BPTC compressed RGB, signed float. + * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. + */ + RGBBptcSignedFloat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, + + /** + * BPTC compressed RGBA, normalized unsigned. + * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. + */ + RGBABptcUnorm = GL_COMPRESSED_RGBA_BPTC_UNORM, + + /** + * BPTC compressed sRGBA, normalized unsigned. + * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. + */ + SRGBAlphaBptcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, + #endif +}; + /** @debugoperatorenum{Magnum::ColorFormat} */ Debug MAGNUM_EXPORT operator<<(Debug debug, ColorFormat value); /** @debugoperatorenum{Magnum::ColorType} */ Debug MAGNUM_EXPORT operator<<(Debug debug, ColorType value); +/** @debugoperatorenum{Magnum::CompressedColorFormat} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, CompressedColorFormat value); + } #endif diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 3f354ab43..10b2bf1a3 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -459,6 +459,7 @@ typedef BasicColor4 Color4ub; enum class ColorFormat: GLenum; enum class ColorType: GLenum; +enum class CompressedColorFormat: GLenum; class Context; diff --git a/src/Magnum/Test/FormatTest.cpp b/src/Magnum/Test/FormatTest.cpp index cb7875590..9259d7465 100644 --- a/src/Magnum/Test/FormatTest.cpp +++ b/src/Magnum/Test/FormatTest.cpp @@ -35,11 +35,13 @@ struct FormatTest: TestSuite::Tester { void debugColorFormat(); void debugColorType(); + void debugCompressedColorFormat(); }; FormatTest::FormatTest() { addTests({&FormatTest::debugColorFormat, - &FormatTest::debugColorType}); + &FormatTest::debugColorType, + &FormatTest::debugCompressedColorFormat}); } void FormatTest::debugColorFormat() { @@ -56,6 +58,17 @@ void FormatTest::debugColorType() { CORRADE_COMPARE(out.str(), "ColorType::UnsignedByte\n"); } +void FormatTest::debugCompressedColorFormat() { + #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"); + #endif +} + }} CORRADE_TEST_MAIN(Magnum::Test::FormatTest)