Browse Source

Renamed ImageType and ImageFormat to ColorType and ColorFormat.

Makes more sense. Added aliases and header file for backwards
compatibility, will be removed in future versions.
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
bc3cbf1ad6
  1. 4
      src/AbstractFramebuffer.cpp
  2. 8
      src/AbstractFramebuffer.h
  3. 94
      src/AbstractImage.cpp
  4. 12
      src/AbstractImage.h
  5. 116
      src/AbstractTexture.cpp
  6. 48
      src/AbstractTexture.h
  7. 2
      src/BufferImage.cpp
  8. 4
      src/BufferImage.h
  9. 3
      src/CMakeLists.txt
  10. 14
      src/ColorFormat.cpp
  11. 481
      src/ColorFormat.h
  12. 2
      src/CubeMapTexture.h
  13. 4
      src/CubeMapTextureArray.h
  14. 2
      src/Image.cpp
  15. 6
      src/Image.h
  16. 449
      src/ImageFormat.h
  17. 4
      src/ImageReference.h
  18. 9
      src/Magnum.h
  19. 10
      src/Test/AbstractImageTest.cpp
  20. 22
      src/Test/ImageTest.cpp
  21. 28
      src/Text/DistanceFieldGlyphCache.cpp
  22. 4
      src/Texture.h
  23. 6
      src/TextureTools/distance-field.cpp
  24. 2
      src/Trade/ImageData.h
  25. 4
      src/Trade/Test/AbstractImageConverterTest.cpp
  26. 22
      src/Trade/Test/ImageDataTest.cpp

4
src/AbstractFramebuffer.cpp

@ -376,12 +376,12 @@ void AbstractFramebuffer::readBufferImplementationDSA(GLenum buffer) {
} }
#endif #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<GLenum>(format), static_cast<GLenum>(type), data); glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES3 #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 */ /** @todo Enable when extension wrangler for ES is available */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), dataSize, data); glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), dataSize, data);

8
src/AbstractFramebuffer.h

@ -150,7 +150,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
AbstractFramebuffer& operator=(AbstractFramebuffer&&) = delete; AbstractFramebuffer& operator=(AbstractFramebuffer&&) = delete;
public: 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 * @brief Max supported viewport size
@ -357,10 +357,10 @@ class MAGNUM_EXPORT AbstractFramebuffer {
void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer); void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer);
#endif #endif
typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ImageFormat, ImageType, std::size_t, GLvoid*); typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ColorFormat, ColorType, 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); 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 #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 #endif
static ReadImplementation MAGNUM_LOCAL readImplementation; static ReadImplementation MAGNUM_LOCAL readImplementation;
}; };

94
src/AbstractImage.cpp

@ -26,117 +26,117 @@
#include <Utility/Assert.h> #include <Utility/Assert.h>
#include "ImageFormat.h" #include "ColorFormat.h"
namespace Magnum { 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; std::size_t size = 0;
switch(type) { switch(type) {
case ImageType::UnsignedByte: case ColorType::UnsignedByte:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageType::Byte: case ColorType::Byte:
#endif #endif
size = 1; break; size = 1; break;
case ImageType::UnsignedShort: case ColorType::UnsignedShort:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageType::Short: case ColorType::Short:
#endif #endif
case ImageType::HalfFloat: case ColorType::HalfFloat:
size = 2; break; size = 2; break;
case ImageType::UnsignedInt: case ColorType::UnsignedInt:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageType::Int: case ColorType::Int:
#endif #endif
case ImageType::Float: case ColorType::Float:
size = 4; break; size = 4; break;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case ImageType::UnsignedByte332: case ColorType::UnsignedByte332:
case ImageType::UnsignedByte233Rev: case ColorType::UnsignedByte233Rev:
return 1; return 1;
#endif #endif
case ImageType::UnsignedShort565: case ColorType::UnsignedShort565:
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case ImageType::UnsignedShort565Rev: case ColorType::UnsignedShort565Rev:
#endif #endif
case ImageType::UnsignedShort4444: case ColorType::UnsignedShort4444:
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
case ImageType::UnsignedShort4444Rev: case ColorType::UnsignedShort4444Rev:
#endif #endif
case ImageType::UnsignedShort5551: case ColorType::UnsignedShort5551:
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
case ImageType::UnsignedShort1555Rev: case ColorType::UnsignedShort1555Rev:
#endif #endif
return 2; return 2;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case ImageType::UnsignedInt8888: case ColorType::UnsignedInt8888:
case ImageType::UnsignedInt8888Rev: case ColorType::UnsignedInt8888Rev:
case ImageType::UnsignedInt1010102: case ColorType::UnsignedInt1010102:
#endif #endif
case ImageType::UnsignedInt2101010Rev: case ColorType::UnsignedInt2101010Rev:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageType::UnsignedInt10F11F11FRev: case ColorType::UnsignedInt10F11F11FRev:
case ImageType::UnsignedInt5999Rev: case ColorType::UnsignedInt5999Rev:
#endif #endif
case ImageType::UnsignedInt248: case ColorType::UnsignedInt248:
return 4; return 4;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageType::Float32UnsignedInt248Rev: case ColorType::Float32UnsignedInt248Rev:
return 8; return 8;
#endif #endif
} }
switch(format) { switch(format) {
case ImageFormat::Red: case ColorFormat::Red:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageFormat::RedInteger: case ColorFormat::RedInteger:
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case ImageFormat::Green: case ColorFormat::Green:
case ImageFormat::Blue: case ColorFormat::Blue:
case ImageFormat::GreenInteger: case ColorFormat::GreenInteger:
case ImageFormat::BlueInteger: case ColorFormat::BlueInteger:
#endif #endif
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
case ImageFormat::Luminance: case ColorFormat::Luminance:
#endif #endif
return 1*size; return 1*size;
case ImageFormat::RG: case ColorFormat::RG:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageFormat::RGInteger: case ColorFormat::RGInteger:
#endif #endif
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
case ImageFormat::LuminanceAlpha: case ColorFormat::LuminanceAlpha:
#endif #endif
return 2*size; return 2*size;
case ImageFormat::RGB: case ColorFormat::RGB:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageFormat::RGBInteger: case ColorFormat::RGBInteger:
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case ImageFormat::BGR: case ColorFormat::BGR:
case ImageFormat::BGRInteger: case ColorFormat::BGRInteger:
#endif #endif
return 3*size; return 3*size;
case ImageFormat::RGBA: case ColorFormat::RGBA:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case ImageFormat::RGBAInteger: case ColorFormat::RGBAInteger:
#endif #endif
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
case ImageFormat::BGRA: case ColorFormat::BGRA:
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case ImageFormat::BGRAInteger: case ColorFormat::BGRAInteger:
#endif #endif
return 4*size; return 4*size;
/* Handled above */ /* Handled above */
case ImageFormat::DepthComponent: case ColorFormat::DepthComponent:
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
case ImageFormat::StencilIndex: case ColorFormat::StencilIndex:
#endif #endif
case ImageFormat::DepthStencil: case ColorFormat::DepthStencil:
CORRADE_ASSERT_UNREACHABLE(); CORRADE_ASSERT_UNREACHABLE();
} }

12
src/AbstractImage.h

@ -54,13 +54,13 @@ class MAGNUM_EXPORT AbstractImage {
* *
* @see pixelSize() const * @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 */ /** @brief Format of pixel data */
constexpr ImageFormat format() const { return _format; } constexpr ColorFormat format() const { return _format; }
/** @brief Data type of pixel data */ /** @brief Data type of pixel data */
constexpr ImageType type() const { return _type; } constexpr ColorType type() const { return _type; }
/** /**
* @brief Pixel size (in bytes) * @brief Pixel size (in bytes)
@ -75,7 +75,7 @@ class MAGNUM_EXPORT AbstractImage {
* @param format Format of pixel data * @param format Format of pixel data
* @param type Data type 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; ~AbstractImage() = default;
@ -84,8 +84,8 @@ class MAGNUM_EXPORT AbstractImage {
#else #else
protected: protected:
#endif #endif
ImageFormat _format; ColorFormat _format;
ImageType _type; ColorType _type;
}; };
} }

116
src/AbstractTexture.cpp

@ -26,10 +26,10 @@
#include "Buffer.h" #include "Buffer.h"
#include "BufferImage.h" #include "BufferImage.h"
#include "ColorFormat.h"
#include "Context.h" #include "Context.h"
#include "Extensions.h" #include "Extensions.h"
#include "Image.h" #include "Image.h"
#include "ImageFormat.h"
#include "Shader.h" #include "Shader.h"
#include "TextureFormat.h" #include "TextureFormat.h"
#include "Implementation/State.h" #include "Implementation/State.h"
@ -284,7 +284,7 @@ void AbstractTexture::initializeContextBasedFunctionality(Context& context) {
#endif #endif
} }
ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) { ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) {
switch(internalFormat) { switch(internalFormat) {
case TextureFormat::Red: case TextureFormat::Red:
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -304,7 +304,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedRedRtgc1: case TextureFormat::CompressedRedRtgc1:
case TextureFormat::CompressedSignedRedRgtc1: case TextureFormat::CompressedSignedRedRgtc1:
#endif #endif
return ImageFormat::Red; return ColorFormat::Red;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::R8UI: case TextureFormat::R8UI:
@ -313,7 +313,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::R16I: case TextureFormat::R16I:
case TextureFormat::R32UI: case TextureFormat::R32UI:
case TextureFormat::R32I: case TextureFormat::R32I:
return ImageFormat::RedInteger; return ColorFormat::RedInteger;
#endif #endif
case TextureFormat::RG: case TextureFormat::RG:
@ -334,7 +334,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedRGRgtc2: case TextureFormat::CompressedRGRgtc2:
case TextureFormat::CompressedSignedRGRgtc2: case TextureFormat::CompressedSignedRGRgtc2:
#endif #endif
return ImageFormat::RG; return ColorFormat::RG;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RG8UI: case TextureFormat::RG8UI:
@ -343,7 +343,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RG16I: case TextureFormat::RG16I:
case TextureFormat::RG32UI: case TextureFormat::RG32UI:
case TextureFormat::RG32I: case TextureFormat::RG32I:
return ImageFormat::RGInteger; return ColorFormat::RGInteger;
#endif #endif
case TextureFormat::RGB: case TextureFormat::RGB:
@ -386,7 +386,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedRGBBptcUnsignedFloat: case TextureFormat::CompressedRGBBptcUnsignedFloat:
case TextureFormat::CompressedRGBBptcSignedFloat: case TextureFormat::CompressedRGBBptcSignedFloat:
#endif #endif
return ImageFormat::RGB; return ColorFormat::RGB;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGB8UI: case TextureFormat::RGB8UI:
@ -395,7 +395,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RGB16I: case TextureFormat::RGB16I:
case TextureFormat::RGB32UI: case TextureFormat::RGB32UI:
case TextureFormat::RGB32I: case TextureFormat::RGB32I:
return ImageFormat::RGBInteger; return ColorFormat::RGBInteger;
#endif #endif
case TextureFormat::RGBA: case TextureFormat::RGBA:
@ -431,7 +431,7 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::CompressedRGBABptcUnorm: case TextureFormat::CompressedRGBABptcUnorm:
case TextureFormat::CompressedSRGBAlphaBptcUnorm: case TextureFormat::CompressedSRGBAlphaBptcUnorm:
#endif #endif
return ImageFormat::RGBA; return ColorFormat::RGBA;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGBA8UI: case TextureFormat::RGBA8UI:
@ -441,14 +441,14 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
case TextureFormat::RGBA32UI: case TextureFormat::RGBA32UI:
case TextureFormat::RGBA32I: case TextureFormat::RGBA32I:
case TextureFormat::RGB10A2UI: case TextureFormat::RGB10A2UI:
return ImageFormat::RGBAInteger; return ColorFormat::RGBAInteger;
#endif #endif
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
case TextureFormat::Luminance: case TextureFormat::Luminance:
return ImageFormat::Luminance; return ColorFormat::Luminance;
case TextureFormat::LuminanceAlpha: case TextureFormat::LuminanceAlpha:
return ImageFormat::LuminanceAlpha; return ColorFormat::LuminanceAlpha;
#endif #endif
case TextureFormat::DepthComponent: case TextureFormat::DepthComponent:
@ -460,11 +460,11 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::DepthComponent32F: case TextureFormat::DepthComponent32F:
#endif #endif
return ImageFormat::DepthComponent; return ColorFormat::DepthComponent;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case TextureFormat::StencilIndex8: case TextureFormat::StencilIndex8:
return ImageFormat::StencilIndex; return ColorFormat::StencilIndex;
#endif #endif
case TextureFormat::DepthStencil: case TextureFormat::DepthStencil:
@ -472,13 +472,13 @@ ImageFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::Depth32FStencil8: case TextureFormat::Depth32FStencil8:
#endif #endif
return ImageFormat::DepthStencil; return ColorFormat::DepthStencil;
} }
CORRADE_ASSERT_UNREACHABLE(); CORRADE_ASSERT_UNREACHABLE();
} }
ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) { ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) {
switch(internalFormat) { switch(internalFormat) {
case TextureFormat::Red: case TextureFormat::Red:
case TextureFormat::RG: case TextureFormat::RG:
@ -519,7 +519,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::CompressedRGBABptcUnorm: case TextureFormat::CompressedRGBABptcUnorm:
case TextureFormat::CompressedSRGBAlphaBptcUnorm: case TextureFormat::CompressedSRGBAlphaBptcUnorm:
#endif #endif
return ImageType::UnsignedByte; return ColorType::UnsignedByte;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::R8Snorm: case TextureFormat::R8Snorm:
@ -534,7 +534,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::CompressedSignedRedRgtc1: case TextureFormat::CompressedSignedRedRgtc1:
case TextureFormat::CompressedSignedRGRgtc2: case TextureFormat::CompressedSignedRGRgtc2:
#endif #endif
return ImageType::Byte; return ColorType::Byte;
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -556,7 +556,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGBA12: /**< @todo really? */ case TextureFormat::RGBA12: /**< @todo really? */
#endif #endif
return ImageType::UnsignedShort; return ColorType::UnsignedShort;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -569,7 +569,7 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::RG16I: case TextureFormat::RG16I:
case TextureFormat::RGB16I: case TextureFormat::RGB16I:
case TextureFormat::RGBA16I: case TextureFormat::RGBA16I:
return ImageType::Short; return ColorType::Short;
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -577,19 +577,19 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::RG16F: case TextureFormat::RG16F:
case TextureFormat::RGB16F: case TextureFormat::RGB16F:
case TextureFormat::RGBA16F: case TextureFormat::RGBA16F:
return ImageType::HalfFloat; return ColorType::HalfFloat;
case TextureFormat::R32UI: case TextureFormat::R32UI:
case TextureFormat::RG32UI: case TextureFormat::RG32UI:
case TextureFormat::RGB32UI: case TextureFormat::RGB32UI:
case TextureFormat::RGBA32UI: case TextureFormat::RGBA32UI:
return ImageType::UnsignedInt; return ColorType::UnsignedInt;
case TextureFormat::R32I: case TextureFormat::R32I:
case TextureFormat::RG32I: case TextureFormat::RG32I:
case TextureFormat::RGB32I: case TextureFormat::RGB32I:
case TextureFormat::RGBA32I: case TextureFormat::RGBA32I:
return ImageType::Int; return ColorType::Int;
case TextureFormat::R32F: case TextureFormat::R32F:
case TextureFormat::RG32F: case TextureFormat::RG32F:
@ -599,24 +599,24 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
case TextureFormat::CompressedRGBBptcUnsignedFloat: case TextureFormat::CompressedRGBBptcUnsignedFloat:
case TextureFormat::CompressedRGBBptcSignedFloat: case TextureFormat::CompressedRGBBptcSignedFloat:
#endif #endif
return ImageType::Float; return ColorType::Float;
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case TextureFormat::R3B3G2: case TextureFormat::R3B3G2:
return ImageType::UnsignedByte332; return ColorType::UnsignedByte332;
case TextureFormat::RGB4: case TextureFormat::RGB4:
return ImageType::UnsignedShort4444; return ColorType::UnsignedShort4444;
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGB5: case TextureFormat::RGB5:
#endif #endif
case TextureFormat::RGB5A1: case TextureFormat::RGB5A1:
return ImageType::UnsignedShort5551; return ColorType::UnsignedShort5551;
case TextureFormat::RGB565: case TextureFormat::RGB565:
return ImageType::UnsignedShort565; return ColorType::UnsignedShort565;
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
case TextureFormat::RGB10: case TextureFormat::RGB10:
@ -625,42 +625,42 @@ ImageType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGB10A2UI: case TextureFormat::RGB10A2UI:
#endif #endif
return ImageType::UnsignedInt2101010Rev; /**< @todo Rev for all? */ return ColorType::UnsignedInt2101010Rev; /**< @todo Rev for all? */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::R11FG11FB10F: case TextureFormat::R11FG11FB10F:
return ImageType::UnsignedInt10F11F11FRev; return ColorType::UnsignedInt10F11F11FRev;
case TextureFormat::RGB9E5: case TextureFormat::RGB9E5:
return ImageType::UnsignedInt5999Rev; return ColorType::UnsignedInt5999Rev;
#endif #endif
case TextureFormat::DepthComponent16: case TextureFormat::DepthComponent16:
return ImageType::UnsignedShort; return ColorType::UnsignedShort;
case TextureFormat::DepthComponent: case TextureFormat::DepthComponent:
case TextureFormat::DepthComponent24: case TextureFormat::DepthComponent24:
#ifndef MAGNUM_TARGET_GLES3 #ifndef MAGNUM_TARGET_GLES3
case TextureFormat::DepthComponent32: case TextureFormat::DepthComponent32:
#endif #endif
return ImageType::UnsignedInt; return ColorType::UnsignedInt;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::DepthComponent32F: case TextureFormat::DepthComponent32F:
return ImageType::Float; return ColorType::Float;
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case TextureFormat::StencilIndex8: case TextureFormat::StencilIndex8:
return ImageType::UnsignedByte; return ColorType::UnsignedByte;
#endif #endif
case TextureFormat::DepthStencil: case TextureFormat::DepthStencil:
case TextureFormat::Depth24Stencil8: case TextureFormat::Depth24Stencil8:
return ImageType::UnsignedInt248; return ColorType::UnsignedInt248;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
case TextureFormat::Depth32FStencil8: case TextureFormat::Depth32FStencil8:
return ImageType::Float32UnsignedInt248Rev; return ColorType::Float32UnsignedInt248Rev;
#endif #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) { 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); CORRADE_INTERNAL_ASSERT(target == GL_TEXTURE_1D);
const ImageFormat format = imageFormatForInternalFormat(internalFormat); const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ImageType type = imageTypeForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat);
for(GLsizei level = 0; level != levels; ++level) { for(GLsizei level = 0; level != levels; ++level) {
(this->*image1DImplementation)(target, level, internalFormat, Math::max(Math::Vector<1, GLsizei>(1), size >> level), format, type, nullptr); (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 #endif
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
const ImageFormat format = imageFormatForInternalFormat(internalFormat); const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ImageType type = imageTypeForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic types */ /* Common code for classic types */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -802,8 +802,8 @@ void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, Te
#endif #endif
void AbstractTexture::storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { void AbstractTexture::storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
const ImageFormat format = imageFormatForInternalFormat(internalFormat); const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ImageType type = imageTypeForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic type */ /* Common code for classic type */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -855,16 +855,16 @@ void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, Te
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); bindInternal();
glGetTexImage(target, level, GLenum(format), GLenum(type), data); 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); 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 #ifndef MAGNUM_TARGET_GLES
bindInternal(); bindInternal();
glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data); glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data);
@ -881,28 +881,28 @@ void AbstractTexture::getImageImplementationRobustness(const GLenum target, cons
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); bindInternal();
glTexImage1D(target, level, static_cast<GLint>(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexImage1D(target, level, static_cast<GLint>(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(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<GLenum>(format), static_cast<GLenum>(type), data); glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #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(); bindInternal();
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES #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<GLenum>(format), static_cast<GLenum>(type), data); glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #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(); bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -919,34 +919,34 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex
} }
#ifndef MAGNUM_TARGET_GLES #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<GLenum>(format), static_cast<GLenum>(type), data); glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); bindInternal();
glTexSubImage1D(target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexSubImage1D(target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(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<GLenum>(format), static_cast<GLenum>(type), data); glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #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(); bindInternal();
glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES #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<GLenum>(format), static_cast<GLenum>(type), data); glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #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(); bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -963,7 +963,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
} }
#ifndef MAGNUM_TARGET_GLES #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<GLenum>(format), static_cast<GLenum>(type), data); glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif

48
src/AbstractTexture.h

@ -393,52 +393,52 @@ class MAGNUM_EXPORT AbstractTexture {
static Storage3DImplementation storage3DImplementation; static Storage3DImplementation storage3DImplementation;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
typedef void(AbstractTexture::*GetImageImplementation)(GLenum, GLint, ImageFormat, ImageType, std::size_t, GLvoid*); typedef void(AbstractTexture::*GetImageImplementation)(GLenum, GLint, ColorFormat, ColorType, 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 getImageImplementationDefault(GLenum target, GLint level, ColorFormat format, ColorType 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 getImageImplementationDSA(GLenum target, GLint level, ColorFormat format, ColorType 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); void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static MAGNUM_LOCAL GetImageImplementation getImageImplementation; static MAGNUM_LOCAL GetImageImplementation getImageImplementation;
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
typedef void(AbstractTexture::*Image1DImplementation)(GLenum, GLint, TextureFormat, const Math::Vector<1, GLsizei>&, ImageFormat, ImageType, const GLvoid*); 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, ImageFormat format, ImageType type, const GLvoid* data); 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, ImageFormat format, ImageType 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; static Image1DImplementation image1DImplementation;
#endif #endif
typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, TextureFormat, const Vector2i&, ImageFormat, ImageType, const GLvoid*); 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, ImageFormat format, ImageType type, const GLvoid* data); void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES #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 #endif
static Image2DImplementation image2DImplementation; static Image2DImplementation image2DImplementation;
typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, TextureFormat, const Vector3i&, ImageFormat, ImageType, const GLvoid*); 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, ImageFormat format, ImageType type, const GLvoid* data); void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES #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 #endif
static Image3DImplementation image3DImplementation; static Image3DImplementation image3DImplementation;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
typedef void(AbstractTexture::*SubImage1DImplementation)(GLenum, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, ImageFormat, ImageType, const GLvoid*); 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, ImageFormat format, ImageType type, const GLvoid* data); 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, 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, ColorFormat format, ColorType type, const GLvoid* data);
static SubImage1DImplementation subImage1DImplementation; static SubImage1DImplementation subImage1DImplementation;
#endif #endif
typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Vector2i&, const Vector2i&, ImageFormat, ImageType, const GLvoid*); 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, ImageFormat format, ImageType type, const GLvoid* data); 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 #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 #endif
static SubImage2DImplementation subImage2DImplementation; static SubImage2DImplementation subImage2DImplementation;
typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Vector3i&, const Vector3i&, ImageFormat, ImageType, const GLvoid*); 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, ImageFormat format, ImageType type, const GLvoid* data); 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 #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 #endif
static SubImage3DImplementation subImage3DImplementation; static SubImage3DImplementation subImage3DImplementation;
@ -458,8 +458,8 @@ class MAGNUM_EXPORT AbstractTexture {
void MAGNUM_LOCAL destroy(); void MAGNUM_LOCAL destroy();
void MAGNUM_LOCAL move(); void MAGNUM_LOCAL move();
ImageFormat MAGNUM_LOCAL imageFormatForInternalFormat(TextureFormat internalFormat); ColorFormat MAGNUM_LOCAL imageFormatForInternalFormat(TextureFormat internalFormat);
ImageType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat); ColorType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat);
GLuint _id; GLuint _id;
}; };

2
src/BufferImage.cpp

@ -27,7 +27,7 @@
namespace Magnum { namespace Magnum {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type, const void* data, Buffer::Usage usage) { template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, Buffer::Usage usage) {
_format = format; _format = format;
_type = type; _type = type;
_size = size; _size = size;

4
src/BufferImage.h

@ -58,7 +58,7 @@ template<UnsignedInt dimensions> class MAGNUM_EXPORT BufferImage: public Abstrac
* Dimensions and buffer are empty, call setData() to fill the image * Dimensions and buffer are empty, call setData() to fill the image
* with data. * 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); _buffer.setTargetHint(Buffer::Target::PixelPack);
} }
@ -81,7 +81,7 @@ template<UnsignedInt dimensions> class MAGNUM_EXPORT BufferImage: public Abstrac
* *
* @see Buffer::setData() * @see Buffer::setData()
*/ */
void setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type, const void* data, Buffer::Usage usage); void setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, Buffer::Usage usage);
private: private:
Math::Vector<Dimensions, Int> _size; Math::Vector<Dimensions, Int> _size;

3
src/CMakeLists.txt

@ -51,12 +51,12 @@ set(Magnum_SRCS
AbstractTexture.cpp AbstractTexture.cpp
AbstractShaderProgram.cpp AbstractShaderProgram.cpp
Buffer.cpp Buffer.cpp
ColorFormat.cpp
Context.cpp Context.cpp
DebugMarker.cpp DebugMarker.cpp
DefaultFramebuffer.cpp DefaultFramebuffer.cpp
Framebuffer.cpp Framebuffer.cpp
Image.cpp Image.cpp
ImageFormat.cpp
Mesh.cpp Mesh.cpp
MeshView.cpp MeshView.cpp
OpenGL.cpp OpenGL.cpp
@ -107,6 +107,7 @@ set(Magnum_HEADERS
Array.h Array.h
Buffer.h Buffer.h
Color.h Color.h
ColorFormat.h
Context.h Context.h
CubeMapTexture.h CubeMapTexture.h
DebugMarker.h DebugMarker.h

14
src/ImageFormat.cpp → src/ColorFormat.cpp

@ -22,16 +22,16 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include "ImageFormat.h" #include "ColorFormat.h"
#include <Utility/Debug.h> #include <Utility/Debug.h>
namespace Magnum { namespace Magnum {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
Debug operator<<(Debug debug, ImageFormat value) { Debug operator<<(Debug debug, const ColorFormat value) {
switch(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) _c(Red)
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
_c(Green) _c(Green)
@ -74,12 +74,12 @@ Debug operator<<(Debug debug, ImageFormat value) {
#undef _c #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) { switch(value) {
#define _c(value) case ImageType::value: return debug << "ImageType::" #value; #define _c(value) case ColorType::value: return debug << "ColorType::" #value;
_c(UnsignedByte) _c(UnsignedByte)
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
_c(Byte) _c(Byte)
@ -127,7 +127,7 @@ Debug operator<<(Debug debug, ImageType value) {
#undef _c #undef _c
} }
return debug << "ImageType::(invalid)"; return debug << "ColorType::(invalid)";
} }
#endif #endif

481
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š <mosra@centrum.cz>
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

2
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 Common usage is to fully configure all texture parameters and then set the
data from e.g. set of Image objects: data from e.g. set of Image objects:
@code @code
Image2D positiveX({256, 256}, ImageFormat::RGBA, ImageType::UnsignedByte, dataPositiveX); Image2D positiveX({256, 256}, ColorFormat::RGBA, ColorType::UnsignedByte, dataPositiveX);
// ... // ...
CubeMapTexture texture; CubeMapTexture texture;

4
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 Example: array with 16 layers of cube map faces, each face consisting of six
64x64 images: 64x64 images:
@code @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; CubeMapTextureArray texture;
texture.setMagnificationFilter(Sampler::Filter::Linear) texture.setMagnificationFilter(Sampler::Filter::Linear)
@ -57,7 +57,7 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
for(std::size_t i = 0; i != 16; ++i) { for(std::size_t i = 0; i != 16; ++i) {
void* dataPositiveX = ...; 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::PositiveX, 0, {}, imagePositiveX);
texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX);

2
src/Image.cpp

@ -26,7 +26,7 @@
namespace Magnum { namespace Magnum {
template<UnsignedInt dimensions> void Image<dimensions>::setData(ImageFormat format, ImageType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data) { template<UnsignedInt dimensions> void Image<dimensions>::setData(ColorFormat format, ColorType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data) {
delete[] _data; delete[] _data;
_format = format; _format = format;
_type = type; _type = type;

6
src/Image.h

@ -53,7 +53,7 @@ template<UnsignedInt dimensions> class Image: public AbstractImage {
* Note that the image data are not copied on construction, but they * Note that the image data are not copied on construction, but they
* are deleted on class destruction. * are deleted on class destruction.
*/ */
explicit Image(ImageFormat format, ImageType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {} explicit Image(ColorFormat format, ColorType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {}
/** /**
* @brief Constructor * @brief Constructor
@ -63,7 +63,7 @@ template<UnsignedInt dimensions> class Image: public AbstractImage {
* Dimensions and data pointer are set to zero, call setData() to fill * Dimensions and data pointer are set to zero, call setData() to fill
* the image with data. * 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 */ /** @brief Copying is not allowed */
Image(const Image<dimensions>&& other) = delete; Image(const Image<dimensions>&& other) = delete;
@ -104,7 +104,7 @@ template<UnsignedInt dimensions> class Image: public AbstractImage {
* Deletes previous data and replaces them with new. Note that the * Deletes previous data and replaces them with new. Note that the
* data are not copied, but they are deleted on destruction. * data are not copied, but they are deleted on destruction.
*/ */
void setData(ImageFormat format, ImageType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data); void setData(ColorFormat format, ColorType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data);
private: private:
Math::Vector<Dimensions, Int> _size; Math::Vector<Dimensions, Int> _size;

449
src/ImageFormat.h

@ -25,456 +25,25 @@
*/ */
/** @file /** @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 "ColorFormat.h"
#include "OpenGL.h"
#include "magnumVisibility.h"
namespace Magnum { namespace Magnum {
/** /**
@brief Format of image data @copybrief ColorFormat
@deprecated Use @ref ColorFormat instead.
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 ImageFormat: GLenum { typedef ColorFormat ImageFormat;
/**
* 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
};
/** /**
@brief Type of image data @copybrief ColorType
@deprecated Use @ref ColorType instead.
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 ImageType: GLenum { typedef ColorType ImageType;
/** 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);
} }

4
src/ImageReference.h

@ -63,7 +63,7 @@ template<UnsignedInt dimensions> class ImageReference: public AbstractImage {
* Note that the image data are not copied on construction, but they * Note that the image data are not copied on construction, but they
* are deleted on class destruction. * are deleted on class destruction.
*/ */
constexpr explicit ImageReference(ImageFormat format, ImageType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {} constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {}
/** /**
* @brief Constructor * @brief Constructor
@ -74,7 +74,7 @@ template<UnsignedInt dimensions> class ImageReference: public AbstractImage {
* Data pointer is set to zero, call setData() to fill the image with * Data pointer is set to zero, call setData() to fill the image with
* data. * data.
*/ */
constexpr explicit ImageReference(ImageFormat format, ImageType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size): AbstractImage(format, type), _size(size), _data(nullptr) {} constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size): AbstractImage(format, type), _size(size), _data(nullptr) {}
/** @brief %Image size */ /** @brief %Image size */
constexpr typename DimensionTraits<Dimensions, Int>::VectorType size() const { return _size; } constexpr typename DimensionTraits<Dimensions, Int>::VectorType size() const { return _size; }

9
src/Magnum.h

@ -347,6 +347,12 @@ template<class> class BasicColor4;
typedef BasicColor3<Float> Color3; typedef BasicColor3<Float> Color3;
typedef BasicColor4<Float> Color4; typedef BasicColor4<Float> 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; enum class Version: Int;
class Context; class Context;
class CubeMapTexture; class CubeMapTexture;
@ -367,9 +373,6 @@ typedef Image<1> Image1D;
typedef Image<2> Image2D; typedef Image<2> Image2D;
typedef Image<3> Image3D; typedef Image<3> Image3D;
enum class ImageFormat: GLenum;
enum class ImageType: GLenum;
template<UnsignedInt> class ImageReference; template<UnsignedInt> class ImageReference;
typedef ImageReference<1> ImageReference1D; typedef ImageReference<1> ImageReference1D;
typedef ImageReference<2> ImageReference2D; typedef ImageReference<2> ImageReference2D;

10
src/Test/AbstractImageTest.cpp

@ -26,7 +26,7 @@
#include <TestSuite/Tester.h> #include <TestSuite/Tester.h>
#include "AbstractImage.h" #include "AbstractImage.h"
#include "ImageFormat.h" #include "ColorFormat.h"
namespace Magnum { namespace Test { namespace Magnum { namespace Test {
@ -45,14 +45,14 @@ AbstractImageTest::AbstractImageTest() {
void AbstractImageTest::debugFormat() { void AbstractImageTest::debugFormat() {
std::ostringstream o; std::ostringstream o;
Debug(&o) << ImageFormat::RGBA; Debug(&o) << ColorFormat::RGBA;
CORRADE_COMPARE(o.str(), "ImageFormat::RGBA\n"); CORRADE_COMPARE(o.str(), "ColorFormat::RGBA\n");
} }
void AbstractImageTest::debugType() { void AbstractImageTest::debugType() {
std::ostringstream o; std::ostringstream o;
Debug(&o) << ImageType::UnsignedShort5551; Debug(&o) << ColorType::UnsignedShort5551;
CORRADE_COMPARE(o.str(), "ImageType::UnsignedShort5551\n"); CORRADE_COMPARE(o.str(), "ColorType::UnsignedShort5551\n");
} }
}} }}

22
src/Test/ImageTest.cpp

@ -24,8 +24,8 @@
#include <TestSuite/Tester.h> #include <TestSuite/Tester.h>
#include "ColorFormat.h"
#include "Image.h" #include "Image.h"
#include "ImageFormat.h"
namespace Magnum { namespace Test { namespace Magnum { namespace Test {
@ -46,36 +46,36 @@ ImageTest::ImageTest() {
void ImageTest::moveConstructor() { void ImageTest::moveConstructor() {
unsigned char* data = new unsigned char[3]; 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)); Image2D b(std::move(a));
CORRADE_VERIFY(!a.data()); CORRADE_VERIFY(!a.data());
CORRADE_COMPARE(b.format(), ImageFormat::Red); CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_VERIFY(b.data() == data); CORRADE_VERIFY(b.data() == data);
} }
void ImageTest::moveAssignment() { void ImageTest::moveAssignment() {
unsigned char* data = new unsigned char[3]; 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); b = std::move(a);
CORRADE_VERIFY(!a.data()); CORRADE_VERIFY(!a.data());
CORRADE_COMPARE(b.format(), ImageFormat::Red); CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_VERIFY(b.data() == data); CORRADE_VERIFY(b.data() == data);
} }
void ImageTest::toReference() { void ImageTest::toReference() {
unsigned char* data = new unsigned char[3]; 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; ImageReference2D b = a;
CORRADE_COMPARE(b.format(), ImageFormat::Red); CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_VERIFY(b.data() == data); CORRADE_VERIFY(b.data() == data);
} }

28
src/Text/DistanceFieldGlyphCache.cpp

@ -24,10 +24,10 @@
#include "DistanceFieldGlyphCache.h" #include "DistanceFieldGlyphCache.h"
#include "Extensions.h"
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
#include "ImageFormat.h" #include "ColorFormat.h"
#endif #endif
#include "Extensions.h"
#include "ImageReference.h" #include "ImageReference.h"
#include "TextureFormat.h" #include "TextureFormat.h"
#include "TextureTools/DistanceField.h" #include "TextureTools/DistanceField.h"
@ -58,18 +58,18 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c
void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) { void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageReference2D& image) {
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
const TextureFormat internalFormat = TextureFormat::R8; const TextureFormat internalFormat = TextureFormat::R8;
CORRADE_ASSERT(image.format() == ImageFormat::Red, CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
#else #else
TextureFormat internalFormat; TextureFormat internalFormat;
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>()) { if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>()) {
internalFormat = TextureFormat::Red; internalFormat = TextureFormat::Red;
CORRADE_ASSERT(image.format() == ImageFormat::Red, CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
} else { } else {
internalFormat = TextureFormat::Luminance; internalFormat = TextureFormat::Luminance;
CORRADE_ASSERT(image.format() == ImageFormat::Luminance, CORRADE_ASSERT(image.format() == ColorFormat::Luminance,
"Text::DistanceFieldGlyphCache::setImage(): expected" << ImageFormat::Luminance << "but got" << image.format(), ); "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Luminance << "but got" << image.format(), );
} }
#endif #endif
@ -85,16 +85,16 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageRefere
void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageReference2D& image) { void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, const ImageReference2D& image) {
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
CORRADE_ASSERT(image.format() == ImageFormat::Red, CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
#else #else
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>()) if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>())
CORRADE_ASSERT(image.format() == ImageFormat::Red, CORRADE_ASSERT(image.format() == ColorFormat::Red,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::Red << "but got" << image.format(), ); "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), );
/* Luminance is not renderable in most cases */ /* Luminance is not renderable in most cases */
else CORRADE_ASSERT(image.format() == ImageFormat::RGB, else CORRADE_ASSERT(image.format() == ColorFormat::RGB,
"Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ImageFormat::RGB << "but got" << image.format(), ); "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::RGB << "but got" << image.format(), );
#endif #endif
texture().setSubImage(0, offset, image); texture().setSubImage(0, offset, image);

4
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: trilinear anisotropic filtering, i.e. the best you can ask for:
@code @code
void* data; void* data;
Image2D image({4096, 4096}, ImageFormat::RGBA, ImageType::UnsignedByte, data); Image2D image({4096, 4096}, ColorFormat::RGBA, ColorType::UnsignedByte, data);
Texture2D texture; Texture2D texture;
texture.setMagnificationFilter(Sampler::Filter::Linear) texture.setMagnificationFilter(Sampler::Filter::Linear)
@ -89,7 +89,7 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
for(std::size_t i = 0; i != 16; ++i) { for(std::size_t i = 0; i != 16; ++i) {
void* data = ...; 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); texture.setSubImage(0, Vector3i::zAxis(i), image);
} }

6
src/TextureTools/distance-field.cpp

@ -26,8 +26,8 @@
#include <PluginManager/Manager.h> #include <PluginManager/Manager.h>
#include "Math/Geometry/Rectangle.h" #include "Math/Geometry/Rectangle.h"
#include "ColorFormat.h"
#include "Image.h" #include "Image.h"
#include "ImageFormat.h"
#include "Renderer.h" #include "Renderer.h"
#include "Texture.h" #include "Texture.h"
#include "TextureFormat.h" #include "TextureFormat.h"
@ -90,7 +90,7 @@ int DistanceFieldConverter::exec() {
return 1; return 1;
} }
if(image->format() != ImageFormat::Red) { if(image->format() != ColorFormat::Red) {
Error() << "Unsupported image format" << image->format(); Error() << "Unsupported image format" << image->format();
return 1; return 1;
} }
@ -113,7 +113,7 @@ int DistanceFieldConverter::exec() {
TextureTools::distanceField(input, output, {{}, args.value<Vector2i>("output-size")}, args.value<Int>("radius"), image->size()); TextureTools::distanceField(input, output, {{}, args.value<Vector2i>("output-size")}, args.value<Int>("radius"), image->size());
/* Save image */ /* Save image */
Image2D result(ImageFormat::Red, ImageType::UnsignedByte); Image2D result(ColorFormat::Red, ColorType::UnsignedByte);
output.image(0, result); output.image(0, result);
if(!converter->exportToFile(result, args.value("output"))) { if(!converter->exportToFile(result, args.value("output"))) {
Error() << "Cannot save file" << args.value("output"); Error() << "Cannot save file" << args.value("output");

2
src/Trade/ImageData.h

@ -53,7 +53,7 @@ template<UnsignedInt dimensions> class ImageData: public AbstractImage {
* Note that the image data are not copied on construction, but they * Note that the image data are not copied on construction, but they
* are deleted on class destruction. * are deleted on class destruction.
*/ */
explicit ImageData(ImageFormat format, ImageType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {} explicit ImageData(ColorFormat format, ColorType type, const typename DimensionTraits<Dimensions, Int>::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {}
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
ImageData(const ImageData<dimensions>&& other) = delete; ImageData(const ImageData<dimensions>&& other) = delete;

4
src/Trade/Test/AbstractImageConverterTest.cpp

@ -27,7 +27,7 @@
#include <TestSuite/Compare/FileToString.h> #include <TestSuite/Compare/FileToString.h>
#include <Utility/Directory.h> #include <Utility/Directory.h>
#include "ImageFormat.h" #include "ColorFormat.h"
#include "ImageReference.h" #include "ImageReference.h"
#include "Trade/AbstractImageConverter.h" #include "Trade/AbstractImageConverter.h"
@ -64,7 +64,7 @@ void AbstractImageConverterTest::exportToFile() {
/* doExportToFile() should call doExportToData() */ /* doExportToFile() should call doExportToData() */
DataExporter exporter; 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_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"), CORRADE_COMPARE_AS(Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"),
"\xFE\xED", TestSuite::Compare::FileToString); "\xFE\xED", TestSuite::Compare::FileToString);

22
src/Trade/Test/ImageDataTest.cpp

@ -24,7 +24,7 @@
#include <TestSuite/Tester.h> #include <TestSuite/Tester.h>
#include "ImageFormat.h" #include "ColorFormat.h"
#include "Trade/ImageData.h" #include "Trade/ImageData.h"
namespace Magnum { namespace Trade { namespace Test { namespace Magnum { namespace Trade { namespace Test {
@ -46,36 +46,36 @@ ImageDataTest::ImageDataTest() {
void ImageDataTest::moveConstructor() { void ImageDataTest::moveConstructor() {
unsigned char* data = new unsigned char[3]; 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)); Trade::ImageData2D b(std::move(a));
CORRADE_VERIFY(!a.data()); CORRADE_VERIFY(!a.data());
CORRADE_COMPARE(b.format(), ImageFormat::Red); CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_VERIFY(b.data() == data); CORRADE_VERIFY(b.data() == data);
} }
void ImageDataTest::moveAssignment() { void ImageDataTest::moveAssignment() {
unsigned char* data = new unsigned char[3]; 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); b = std::move(a);
CORRADE_VERIFY(!a.data()); CORRADE_VERIFY(!a.data());
CORRADE_COMPARE(b.format(), ImageFormat::Red); CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_VERIFY(b.data() == data); CORRADE_VERIFY(b.data() == data);
} }
void ImageDataTest::toReference() { void ImageDataTest::toReference() {
unsigned char* data = new unsigned char[3]; 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; ImageReference2D b = a;
CORRADE_COMPARE(b.format(), ImageFormat::Red); CORRADE_COMPARE(b.format(), ColorFormat::Red);
CORRADE_COMPARE(b.type(), ImageType::UnsignedByte); CORRADE_COMPARE(b.type(), ColorType::UnsignedByte);
CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.size(), Vector2i(1, 3));
CORRADE_COMPARE(b.data(), data); CORRADE_COMPARE(b.data(), data);
} }

Loading…
Cancel
Save