diff --git a/doc/method-chaining.dox b/doc/method-chaining.dox index df77cfd54..3c8f99407 100644 --- a/doc/method-chaining.dox +++ b/doc/method-chaining.dox @@ -43,9 +43,9 @@ number of needed bindings. Consider the following example: @code Texture2D *carDiffuseTexture, *carSpecularTexture, *carBumpTexture; -carDiffuseTexture->setStorage(5, Texture2D::InternalFormat::SRGB8); -carSpecularTexture->setStorage(3, Texture2D::InternalFormat::R8); -carBumpTexture->setStorage(5, Texture2D::InternalFormat::RGB8); +carDiffuseTexture->setStorage(5, TextureFormat::SRGB8); +carSpecularTexture->setStorage(3, TextureFormat::R8); +carBumpTexture->setStorage(5, TextureFormat::RGB8); carDiffuseTexture->setSubImage(0, {}, diffuse); carSpecularTexture->setSubImage(0, {}, specular; carBumpTexture->setSubImage(0, {}, bump); @@ -61,13 +61,13 @@ names and after each configuration step the texture must be rebound to another. With method chaining used the code looks much lighter and each object is configured in one run, reducing count of bind calls from 9 to 3. @code -carDiffuseTexture->setStorage(5, Texture2D::InternalFormat::SRGB8) +carDiffuseTexture->setStorage(5, TextureFormat::SRGB8) ->setSubImage(0, {}, diffuse) ->generateMipmap(); -carSpecularTexture->setStorage(3, Texture2D::InternalFormat::R8) +carSpecularTexture->setStorage(3, TextureFormat::R8) ->setSubImage(0, {}, diffuse) ->generateMipmap(); -carBumpTexture->setStorage(5, Texture2D::InternalFormat::RGB8) +carBumpTexture->setStorage(5, TextureFormat::RGB8) ->setSubImage(0, {}, bump) ->generateMipmap(); @endcode diff --git a/src/AbstractFramebuffer.cpp b/src/AbstractFramebuffer.cpp index b7086b2c4..951560ede 100644 --- a/src/AbstractFramebuffer.cpp +++ b/src/AbstractFramebuffer.cpp @@ -267,12 +267,12 @@ void AbstractFramebuffer::readBufferImplementationDSA(GLenum buffer) { } #endif -void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, const Vector2i& size, const AbstractImage::Format format, const AbstractImage::Type type, const std::size_t, GLvoid* const data) { +void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, const Vector2i& size, const ImageFormat format, const ImageType type, const std::size_t, GLvoid* const data) { glReadPixels(offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES3 -void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const AbstractImage::Format format, const AbstractImage::Type type, const std::size_t dataSize, GLvoid* const data) { +void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const ImageFormat format, const ImageType type, const std::size_t dataSize, GLvoid* const data) { /** @todo Enable when extension wrangler for ES is available */ #ifndef MAGNUM_TARGET_GLES glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), dataSize, data); diff --git a/src/AbstractFramebuffer.h b/src/AbstractFramebuffer.h index 49e28697c..2abcb669b 100644 --- a/src/AbstractFramebuffer.h +++ b/src/AbstractFramebuffer.h @@ -31,7 +31,6 @@ #include #include "Math/Geometry/Rectangle.h" -#include "AbstractImage.h" #include "Buffer.h" namespace Magnum { @@ -308,10 +307,10 @@ class MAGNUM_EXPORT AbstractFramebuffer { void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer); #endif - typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, AbstractImage::Format, AbstractImage::Type, std::size_t, GLvoid*); - static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, std::size_t dataSize, GLvoid* data); + typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ImageFormat, ImageType, std::size_t, GLvoid*); + static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); #ifndef MAGNUM_TARGET_GLES3 - static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, std::size_t dataSize, GLvoid* data); + static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); #endif static ReadImplementation MAGNUM_LOCAL readImplementation; }; diff --git a/src/AbstractImage.cpp b/src/AbstractImage.cpp index 761f15dd8..8c70d25ec 100644 --- a/src/AbstractImage.cpp +++ b/src/AbstractImage.cpp @@ -26,109 +26,111 @@ #include +#include "ImageFormat.h" + namespace Magnum { -std::size_t AbstractImage::pixelSize(Format format, Type type) { +std::size_t AbstractImage::pixelSize(ImageFormat format, ImageType type) { std::size_t size = 0; switch(type) { - case Type::UnsignedByte: + case ImageType::UnsignedByte: #ifndef MAGNUM_TARGET_GLES2 - case Type::Byte: + case ImageType::Byte: #endif size = 1; break; - case Type::UnsignedShort: + case ImageType::UnsignedShort: #ifndef MAGNUM_TARGET_GLES2 - case Type::Short: + case ImageType::Short: #endif - case Type::HalfFloat: + case ImageType::HalfFloat: size = 2; break; - case Type::UnsignedInt: + case ImageType::UnsignedInt: #ifndef MAGNUM_TARGET_GLES2 - case Type::Int: + case ImageType::Int: #endif - case Type::Float: + case ImageType::Float: size = 4; break; #ifndef MAGNUM_TARGET_GLES - case Type::UnsignedByte332: - case Type::UnsignedByte233Rev: + case ImageType::UnsignedByte332: + case ImageType::UnsignedByte233Rev: return 1; #endif - case Type::UnsignedShort565: + case ImageType::UnsignedShort565: #ifndef MAGNUM_TARGET_GLES - case Type::UnsignedShort565Rev: + case ImageType::UnsignedShort565Rev: #endif - case Type::UnsignedShort4444: + case ImageType::UnsignedShort4444: #ifndef MAGNUM_TARGET_GLES3 - case Type::UnsignedShort4444Rev: + case ImageType::UnsignedShort4444Rev: #endif - case Type::UnsignedShort5551: + case ImageType::UnsignedShort5551: #ifndef MAGNUM_TARGET_GLES3 - case Type::UnsignedShort1555Rev: + case ImageType::UnsignedShort1555Rev: #endif return 2; #ifndef MAGNUM_TARGET_GLES - case Type::UnsignedInt8888: - case Type::UnsignedInt8888Rev: - case Type::UnsignedInt1010102: + case ImageType::UnsignedInt8888: + case ImageType::UnsignedInt8888Rev: + case ImageType::UnsignedInt1010102: #endif - case Type::UnsignedInt2101010Rev: + case ImageType::UnsignedInt2101010Rev: #ifndef MAGNUM_TARGET_GLES2 - case Type::UnsignedInt10F11F11FRev: - case Type::UnsignedInt5999Rev: + case ImageType::UnsignedInt10F11F11FRev: + case ImageType::UnsignedInt5999Rev: #endif - case Type::UnsignedInt248: + case ImageType::UnsignedInt248: return 4; #ifndef MAGNUM_TARGET_GLES2 - case Type::Float32UnsignedInt248Rev: + case ImageType::Float32UnsignedInt248Rev: return 8; #endif } switch(format) { - case Format::Red: + case ImageFormat::Red: #ifndef MAGNUM_TARGET_GLES2 - case Format::RedInteger: + case ImageFormat::RedInteger: #endif #ifndef MAGNUM_TARGET_GLES - case Format::Green: - case Format::Blue: - case Format::GreenInteger: - case Format::BlueInteger: + case ImageFormat::Green: + case ImageFormat::Blue: + case ImageFormat::GreenInteger: + case ImageFormat::BlueInteger: #endif return 1*size; - case Format::RG: + case ImageFormat::RG: #ifndef MAGNUM_TARGET_GLES2 - case Format::RGInteger: + case ImageFormat::RGInteger: #endif return 2*size; - case Format::RGB: + case ImageFormat::RGB: #ifndef MAGNUM_TARGET_GLES2 - case Format::RGBInteger: + case ImageFormat::RGBInteger: #endif #ifndef MAGNUM_TARGET_GLES - case Format::BGR: - case Format::BGRInteger: + case ImageFormat::BGR: + case ImageFormat::BGRInteger: #endif return 3*size; - case Format::RGBA: + case ImageFormat::RGBA: #ifndef MAGNUM_TARGET_GLES2 - case Format::RGBAInteger: + case ImageFormat::RGBAInteger: #endif #ifndef MAGNUM_TARGET_GLES3 - case Format::BGRA: + case ImageFormat::BGRA: #endif #ifndef MAGNUM_TARGET_GLES - case Format::BGRAInteger: + case ImageFormat::BGRAInteger: #endif return 4*size; /* Handled above */ - case Format::DepthComponent: + case ImageFormat::DepthComponent: #ifndef MAGNUM_TARGET_GLES3 - case Format::StencilIndex: + case ImageFormat::StencilIndex: #endif - case Format::DepthStencil: + case ImageFormat::DepthStencil: CORRADE_ASSERT_UNREACHABLE(); } @@ -136,101 +138,4 @@ std::size_t AbstractImage::pixelSize(Format format, Type type) { return 0; } -#ifndef DOXYGEN_GENERATING_OUTPUT -Debug operator<<(Debug debug, AbstractImage::Format value) { - switch(value) { - #define _c(value) case AbstractImage::Format::value: return debug << "AbstractImage::Format::" #value; - _c(Red) - #ifndef MAGNUM_TARGET_GLES - _c(Green) - _c(Blue) - #endif - _c(RG) - _c(RGB) - _c(RGBA) - #ifndef MAGNUM_TARGET_GLES - _c(BGR) - #endif - #ifndef MAGNUM_TARGET_GLES3 - _c(BGRA) - #endif - #ifndef MAGNUM_TARGET_GLES2 - _c(RedInteger) - #ifndef MAGNUM_TARGET_GLES - _c(GreenInteger) - _c(BlueInteger) - #endif - _c(RGInteger) - _c(RGBInteger) - _c(RGBAInteger) - #ifndef MAGNUM_TARGET_GLES - _c(BGRInteger) - _c(BGRAInteger) - #endif - #endif - _c(DepthComponent) - #ifndef MAGNUM_TARGET_GLES3 - _c(StencilIndex) - #endif - _c(DepthStencil) - #undef _c - } - - return debug << "AbstractImage::Format::(invalid)"; -} - -Debug operator<<(Debug debug, AbstractImage::Type value) { - switch(value) { - #define _c(value) case AbstractImage::Type::value: return debug << "AbstractImage::Type::" #value; - _c(UnsignedByte) - #ifndef MAGNUM_TARGET_GLES2 - _c(Byte) - #endif - _c(UnsignedShort) - #ifndef MAGNUM_TARGET_GLES2 - _c(Short) - #endif - _c(UnsignedInt) - #ifndef MAGNUM_TARGET_GLES2 - _c(Int) - #endif - _c(HalfFloat) - _c(Float) - #ifndef MAGNUM_TARGET_GLES - _c(UnsignedByte332) - _c(UnsignedByte233Rev) - #endif - _c(UnsignedShort565) - #ifndef MAGNUM_TARGET_GLES - _c(UnsignedShort565Rev) - #endif - _c(UnsignedShort4444) - #ifndef MAGNUM_TARGET_GLES3 - _c(UnsignedShort4444Rev) - #endif - _c(UnsignedShort5551) - #ifndef MAGNUM_TARGET_GLES3 - _c(UnsignedShort1555Rev) - #endif - #ifndef MAGNUM_TARGET_GLES - _c(UnsignedInt8888) - _c(UnsignedInt8888Rev) - _c(UnsignedInt1010102) - #endif - _c(UnsignedInt2101010Rev) - #ifndef MAGNUM_TARGET_GLES2 - _c(UnsignedInt10F11F11FRev) - _c(UnsignedInt5999Rev) - #endif - _c(UnsignedInt248) - #ifndef MAGNUM_TARGET_GLES2 - _c(Float32UnsignedInt248Rev) - #endif - #undef _c - } - - return debug << "AbstractImage::Type::(invalid)"; -} -#endif - } diff --git a/src/AbstractImage.h b/src/AbstractImage.h index 2a03db61c..e602bf17f 100644 --- a/src/AbstractImage.h +++ b/src/AbstractImage.h @@ -31,7 +31,6 @@ #include #include "Magnum.h" -#include "OpenGL.h" #include "magnumVisibility.h" namespace Magnum { @@ -53,442 +52,6 @@ class MAGNUM_EXPORT AbstractImage { AbstractImage& operator=(AbstractImage&&) = delete; public: - /** - * @{ @name Image formats - * - * Note that some formats can be used only for framebuffer reading - * (using Framebuffer::read()) and some only for texture data (using - * Texture::setImage() and others). - */ - - /** - * @brief Format of pixel data - * - * @see pixelSize(Format, Type) - */ - enum class Format: 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::AbstractImage::Format "Format::Red" - * is available in OpenGL ES. - */ - Green = GL_GREEN, - - /** - * Floating-point blue channel. - * @requires_gl Only @ref Magnum::AbstractImage::Format "Format::Red" - * is available in OpenGL ES. - */ - Blue = GL_BLUE, - - /** @todo GL_ALPHA? */ - #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 - - /** - * 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::AbstractImage::Format "Format::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::AbstractImage::Format "Format::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::AbstractImage::Format "Format::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::AbstractImage::Format "Format::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. For framebuffer reading only. - * @requires_es_extension %Extension @es_extension2{NV,read_stencil,GL_NV_read_depth_stencil} - * @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{EXT,packed_depth_stencil} - * @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 Data type of pixel data - * - * @see pixelSize(Format, Type) - */ - enum class Type: 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::AbstractImage::Type "Type::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::AbstractImage::Type "Type::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::AbstractImage::Type "Type::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::AbstractImage::Type "Type::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::AbstractImage::Type "Type::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::AbstractImage::Format "Format::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::AbstractImage::Type "Type::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{EXT,packed_depth_stencil} - * @requires_gles30 For texture data only, extension - * @es_extension{OES,packed_depth_stencil}. - */ - #ifdef MAGNUM_TARGET_GLES2 - UnsignedInt248 = GL_UNSIGNED_INT_24_8_OES - #else - UnsignedInt248 = GL_UNSIGNED_INT_24_8, - - /** - * 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::AbstractImage::Type "Type::UnsignedInt248" is - * available in OpenGL ES 2.0. - */ - Float32UnsignedInt248Rev = GL_FLOAT_32_UNSIGNED_INT_24_8_REV - #endif - }; - - /*@}*/ - /** * @brief Pixel size (in bytes) * @param format Format of the pixel @@ -496,23 +59,23 @@ class MAGNUM_EXPORT AbstractImage { * * @see pixelSize() const */ - static std::size_t pixelSize(Format format, Type type); + static std::size_t pixelSize(ImageFormat format, ImageType type); /** * @brief Constructor * @param format Format of pixel data * @param type Data type of pixel data */ - inline explicit AbstractImage(Format format, Type type): _format(format), _type(type) {} + inline explicit AbstractImage(ImageFormat format, ImageType type): _format(format), _type(type) {} /** @brief Destructor */ virtual ~AbstractImage() = 0; /** @brief Format of pixel data */ - inline Format format() const { return _format; } + inline ImageFormat format() const { return _format; } /** @brief Data type of pixel data */ - inline Type type() const { return _type; } + inline ImageType type() const { return _type; } /** * @brief Pixel size (in bytes) @@ -528,18 +91,12 @@ class MAGNUM_EXPORT AbstractImage { #else protected: #endif - Format _format; - Type _type; + ImageFormat _format; + ImageType _type; }; inline AbstractImage::~AbstractImage() {} -/** @debugoperator{Magnum::AbstractImage} */ -Debug MAGNUM_EXPORT operator<<(Debug debug, AbstractImage::Format value); - -/** @debugoperator{Magnum::AbstractImage} */ -Debug MAGNUM_EXPORT operator<<(Debug debug, AbstractImage::Type value); - } #endif diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 7a71667fd..23ce94e86 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -306,7 +306,7 @@ void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint le #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { +void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { bindInternal(); /** @todo Re-enable when extension wrangler is available for ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -320,12 +320,12 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels #endif } -void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { +void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]); } #endif -void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector2i& size) { +void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { bindInternal(); /** @todo Re-enable when extension wrangler is available for ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -340,12 +340,12 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector2i& size) { +void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y()); } #endif -void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector3i& size) { +void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { bindInternal(); /** @todo Re-enable when extension wrangler is available for ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -360,22 +360,22 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector3i& size) { +void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::getImageImplementationDefault(const GLenum target, const GLint level, const AbstractImage::Format format, const AbstractImage::Type type, const std::size_t, GLvoid* const data) { +void AbstractTexture::getImageImplementationDefault(const GLenum target, const GLint level, const ImageFormat format, const ImageType type, const std::size_t, GLvoid* const data) { bindInternal(); glGetTexImage(target, level, GLenum(format), GLenum(type), data); } -void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const AbstractImage::Format format, const AbstractImage::Type type, const std::size_t, GLvoid* const data) { +void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const ImageFormat format, const ImageType type, const std::size_t, GLvoid* const data) { glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data); } -void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const AbstractImage::Format format, const AbstractImage::Type type, const std::size_t dataSize, GLvoid* const data) { +void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ImageFormat format, const ImageType type, const std::size_t dataSize, GLvoid* const data) { #ifndef MAGNUM_TARGET_GLES bindInternal(); glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data); @@ -392,28 +392,28 @@ void AbstractTexture::getImageImplementationRobustness(const GLenum target, cons #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data) { bindInternal(); glTexImage1D(target, level, static_cast(internalFormat), size[0], 0, static_cast(format), static_cast(type), data); } -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data) { glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { bindInternal(); glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast(format), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { bindInternal(); /** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -430,34 +430,34 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Int } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast(format), static_cast(type), data); } #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +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) { bindInternal(); glTexSubImage1D(target, level, offset[0], size[0], static_cast(format), static_cast(type), data); } -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* 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) { glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { bindInternal(); glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data) { glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast(format), static_cast(type), data); } #endif -void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { bindInternal(); /** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 @@ -474,7 +474,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data) { glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast(format), static_cast(type), data); } #endif diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index bfa31a563..c2caff0dd 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -31,9 +31,10 @@ #include "Array.h" #ifndef MAGNUM_TARGET_GLES2 #include "Buffer.h" +#else +#include "OpenGL.h" #endif #include "Color.h" -#include "AbstractImage.h" namespace Magnum { @@ -105,9 +106,9 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 %Extension @es_extension{OES,texture_float_linear} / * @es_extension2{OES,texture_half_float_linear,OES_texture_float_linear} * for linear interpolation of textures with - * @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::HalfFloat" - * / @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::Float" - * in OpenGL ES 2.0. + * @ref Magnum::TextureFormat "TextureFormat::HalfFloat" / + * @ref Magnum::TextureFormat "TextureFormat::Float" in OpenGL + * ES 2.0. */ Linear = GL_LINEAR }; @@ -131,9 +132,9 @@ class MAGNUM_EXPORT AbstractTexture { * @requires_gles30 %Extension @es_extension{OES,texture_float_linear} / * @es_extension2{OES,texture_half_float_linear,OES_texture_float_linear} * for linear interpolation of textures with - * @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::HalfFloat" - * / @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::Float" - * in OpenGL ES 2.0. + * @ref Magnum::TextureFormat "TextureFormat::HalfFloat" / + * @ref Magnum::TextureFormat "TextureFormat::Float" in OpenGL + * ES 2.0. */ Linear = GL_NEAREST_MIPMAP_LINEAR & ~GL_NEAREST }; @@ -172,826 +173,6 @@ class MAGNUM_EXPORT AbstractTexture { #endif }; - /** - * @brief Internal format - * - * @see @ref Texture::setImage() "setImage()" - */ - enum class InternalFormat: GLint { - /** - * Red component, normalized unsigned, size implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::R8". - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gles30 %Extension @es_extension{EXT,texture_rg} - */ - #ifndef MAGNUM_TARGET_GLES2 - Red = GL_RED, - #else - Red = GL_RED_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Red component, normalized unsigned byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::Red" - * in OpenGL ES 2.0 instead. - */ - R8 = GL_R8, - #endif - - /** - * Red and green component, normalized unsigned, size - * implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RG8". - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gles30 %Extension @es_extension{EXT,texture_rg} - */ - #ifndef MAGNUM_TARGET_GLES2 - RG = GL_RG, - #else - RG = GL_RG_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Red and green component, each normalized unsigned byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RG" - * in OpenGL ES 2.0 instead. - */ - RG8 = GL_RG8, - #endif - - /** - * RGB, normalized unsigned, size implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB8". - */ - RGB = GL_RGB, - - /** - * RGB, each component normalized unsigned byte. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat} - */ - #ifndef MAGNUM_TARGET_GLES2 - RGB8 = GL_RGB8, - #else - RGB8 = GL_RGB8_OES, - #endif - - /** - * RGBA, normalized unsigned, size implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGBA8". - */ - RGBA = GL_RGBA, - - /** - * RGBA, each component normalized unsigned byte. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat} - */ - #ifndef MAGNUM_TARGET_GLES2 - RGBA8 = GL_RGBA8, - #else - RGBA8 = GL_RGBA8_OES, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Red component, normalized signed byte. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gles30 Only unsigned formats are available in OpenGL - * ES 2.0. - */ - R8Snorm = GL_R8_SNORM, - - /** - * Red and green component, each normalized signed byte. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gles30 Only unsigned formats are available in OpenGL - * ES 2.0. - */ - RG8Snorm = GL_RG8_SNORM, - - /** - * RGB, each component normalized signed byte. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gles30 Only unsigned formats are available in OpenGL - * ES 2.0. - */ - RGB8Snorm = GL_RGB8_SNORM, - - /** - * RGBA, each component normalized signed byte. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gles30 Only unsigned formats are available in OpenGL - * ES 2.0. - */ - RGBA8Snorm = GL_RGBA8_SNORM, - - #ifndef MAGNUM_TARGET_GLES - /** - * Red component, normalized unsigned short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - R16 = GL_R16, - - /** - * Red and green component, each normalized unsigned short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RG16 = GL_RG16, - - /** - * RGB, each component normalized unsigned short. - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RGB16 = GL_RGB16, - - /** - * RGBA, each component normalized unsigned short. - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RGBA16 = GL_RGBA16, - - /** - * Red component, normalized signed short. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - R16Snorm = GL_R16_SNORM, - - /** - * Red and green component, each normalized signed short. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RG16Snorm = GL_RG16_SNORM, - - /** - * RGB, each component normalized signed short. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RGB16Snorm = GL_RGB16_SNORM, - - /** - * RGBA, each component normalized signed short. - * @requires_gl31 %Extension @extension{EXT,texture_snorm} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RGBA16Snorm = GL_RGBA16_SNORM, - #endif - - /** - * Red component, non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R8UI = GL_R8UI, - - /** - * Red and green component, each non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG8UI = GL_RG8UI, - - /** - * RGB, each component non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB8UI = GL_RGB8UI, - - /** - * RGBA, each component non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA8UI = GL_RGBA8UI, - - /** - * Red component, non-normalized signed byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R8I = GL_R8I, - - /** - * Red and green component, each non-normalized signed byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG8I = GL_RG8I, - - /** - * RGB, each component non-normalized signed byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB8I = GL_RGB8I, - - /** - * RGBA, each component non-normalized signed byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA8I = GL_RGBA8I, - - /** - * Red component, non-normalized unsigned short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R16UI = GL_R16UI, - - /** - * Red and green component, each non-normalized unsigned short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG16UI = GL_RG16UI, - - /** - * RGB, each component non-normalized unsigned short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB16UI = GL_RGB16UI, - - /** - * RGBA, each component non-normalized unsigned short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA16UI = GL_RGBA16UI, - - /** - * Red component, non-normalized signed short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R16I = GL_R16I, - - /** - * Red and green component, each non-normalized signed short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG16I = GL_RG16I, - - /** - * RGB, each component non-normalized signed short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB16I = GL_RGB16I, - - /** - * RGBA, each component non-normalized signed short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA16I = GL_RGBA16I, - - /** - * Red component, non-normalized unsigned int. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R32UI = GL_R32UI, - - /** - * Red and green component, each non-normalized unsigned int. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG32UI = GL_RG32UI, - - /** - * RGB, each component non-normalized unsigned int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB32UI = GL_RGB32UI, - - /** - * RGBA, each component non-normalized unsigned int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA32UI = GL_RGBA32UI, - - /** - * Red component, non-normalized signed int. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R32I = GL_R32I, - - /** - * Red and green component, each non-normalized signed int. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG32I = GL_RG32I, - - /** - * RGB, each component non-normalized signed int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB32I = GL_RGB32I, - - /** - * RGBA, each component non-normalized signed int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA32I = GL_RGBA32I, - - /** - * Red component, half float. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R16F = GL_R16F, - - /** - * Red and green component, each half float. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG16F = GL_RG16F, - - /** - * RGB, each component half float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB16F = GL_RGB16F, - - /** - * RGBA, each component half float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA16F = GL_RGBA16F, - - /** - * Red component, float. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R32F = GL_R32F, - - /** - * Red and green component, each float. - * @requires_gl30 %Extension @extension{ARB,texture_rg} and - * @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG32F = GL_RG32F, - - /** - * RGB, each component float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB32F = GL_RGB32F, - - /** - * RGBA, each component float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA32F = GL_RGBA32F, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * RGB, normalized unsigned, red and green component 3bit, blue - * 2bit. - * @requires_gl Packed 8bit types are not available in OpenGL ES. - */ - R3B3G2 = GL_R3_G3_B2, - - /** - * RGB, each component normalized unsigned 4bit. - * @requires_gl Packed 12bit types are not available in OpenGL ES. - */ - RGB4 = GL_RGB4, - - /** - * RGB, each component normalized unsigned 5bit. - * @requires_gl Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB5A1" - * or @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB565" in OpenGL ES. - */ - RGB5 = GL_RGB5, - #endif - - /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is - GL_ARB_ES2_compatibility */ - #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) - /** - * RGB, normalized unsigned, red and blue component 5bit, green 6bit. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat} - */ - RGB565 = GL_RGB565, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * RGB, each component normalized unsigned 10bit. - * @requires_es_extension %Extension @es_extension{OES,required_internalformat} - * and @es_extension{EXT,texture_type_2_10_10_10_REV} - */ - #ifndef MAGNUM_TARGET_GLES - RGB10 = GL_RGB10, - #else - RGB10 = GL_RGB10_EXT, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * RGB, each component normalized unsigned 12bit. - * @requires_gl Packed 36bit types are not available in OpenGL ES. - */ - RGB12 = GL_RGB12, - - /** - * RGBA, normalized unsigned, each component 2bit. - * @requires_gl Packed 8bit types are not available in OpenGL ES. - */ - RGBA2 = GL_RGBA2, - #endif - - /** - * RGBA, normalized unsigned, each component 4bit. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat} - */ - RGBA4 = GL_RGBA4, - - /** - * RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat} - */ - RGB5A1 = GL_RGB5_A1, - - /** - * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat} - * and @es_extension{EXT,texture_type_2_10_10_10_REV} - */ - #ifndef MAGNUM_TARGET_GLES2 - RGB10A2 = GL_RGB10_A2, - #else - RGB10A2 = GL_RGB10_A2_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * RGBA, non-normalized unsigned, each RGB component 10bit, alpha - * 2bit. - * @requires_gl33 %Extension @extension{ARB,texture_rgb10_a2ui} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB10A2UI = GL_RGB10_A2UI, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * RGBA, each component normalized unsigned 12bit. - * @requires_gl Packed 48bit types are not available in OpenGL ES. - */ - RGBA12 = GL_RGBA12, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * RGB, float, red and green component 11bit, blue 10bit. - * @requires_gl30 %Extension @extension{EXT,packed_float} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R11FG11FB10F = GL_R11F_G11F_B10F, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * RGB, unsigned with exponent, each RGB component 9bit, exponent 5bit. - * @requires_gl30 %Extension @extension{EXT,texture_shared_exponent} - * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB" - * in OpenGL ES 2.0 instead. - */ - RGB9E5 = GL_RGB9_E5, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * sRGB, normalized unsigned, size implementation-dependent. - * @todo is this allowed in core? - * @deprecated Prefer to use the exactly specified version of this - * format, i.e. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8". - * @requires_es_extension %Extension @es_extension{EXT,sRGB} in - * OpenGL ES 2.0, use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8" - * in OpenGL ES 3.0 instead. - */ - #ifndef MAGNUM_TARGET_GLES - SRGB = GL_SRGB, - #else - SRGB = GL_SRGB_EXT, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * sRGB, each component normalized unsigned byte. - * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB" - * in OpenGL ES 2.0 instead. - */ - SRGB8 = GL_SRGB8, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * sRGBA, normalized unsigned, size implementation-dependent. - * @todo is this allowed in core? - * @deprecated Prefer to use the exactly specified version of this - * format, i.e. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8Alpha8". - * @requires_es_extension %Extension @es_extension{EXT,sRGB} in - * OpenGL ES 2.0, use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8Alpha8" - * in OpenGL ES 3.0 instead. - */ - #ifndef MAGNUM_TARGET_GLES - SRGBAlpha = GL_SRGB_ALPHA, - #else - SRGBAlpha = GL_SRGB_ALPHA_EXT, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * sRGBA, each component normalized unsigned byte. - * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGBAlpha" - * in OpenGL ES 2.0 instead. - */ - SRGB8Alpha8 = GL_SRGB8_ALPHA8, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Compressed red channel, normalized unsigned. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Generic texture compression is not available in - * OpenGL ES. - */ - CompressedRed = GL_COMPRESSED_RED, - - /** - * Compressed red and green channel, normalized unsigned. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Generic texture compression is not available in - * OpenGL ES. - */ - CompressedRG = GL_COMPRESSED_RG, - - /** - * Compressed RGB, normalized unsigned. - * @requires_gl Generic texture compression is not available in - * OpenGL ES. - */ - CompressedRGB = GL_COMPRESSED_RGB, - - /** - * Compressed RGBA, normalized unsigned. - * @requires_gl Generic texture compression is not available in - * OpenGL ES. - */ - CompressedRGBA = GL_COMPRESSED_RGBA, - - /** - * RTGC compressed red channel, normalized unsigned. - * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in - * OpenGL ES. - */ - CompressedRedRtgc1 = GL_COMPRESSED_RED_RGTC1, - - /** - * RTGC compressed red and green channel, normalized unsigned. - * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in - * OpenGL ES. - */ - CompressedRGRgtc2 = GL_COMPRESSED_RG_RGTC2, - - /** - * RTGC compressed red channel, normalized signed. - * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in - * OpenGL ES. - */ - CompressedSignedRedRgtc1 = GL_COMPRESSED_SIGNED_RED_RGTC1, - - /** - * RTGC compressed red and green channel, normalized signed. - * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in - * OpenGL ES. - */ - CompressedSignedRGRgtc2 = GL_COMPRESSED_SIGNED_RG_RGTC2, - - /* These are named with _ARB suffix, because glcorearb.h doesn't - have suffixless version (?!) and GLEW has it without suffix as - late as of 1.8.0 { */ - - /** - * BPTC compressed RGBA, normalized unsigned. - * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in - * OpenGL ES. - */ - CompressedRGBABtpcUnorm = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, - - /** - * BPTC compressed sRGBA, normalized unsigned. - * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in - * OpenGL ES. - */ - CompressedSRGBAlphaBtpcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, - - /** - * BPTC compressed RGB, unsigned float. - * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in - * OpenGL ES. - */ - CompressedRGBBptcUnsignedFloat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, - - /** - * BPTC compressed RGB, signed float. - * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in - * OpenGL ES. - */ - CompressedRGBBptcSignedFloat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, - - /*}*/ - #endif - - /** - * Depth component, size implementation-dependent. - * @deprecated Prefer to use exactly specified version of this - * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::DepthComponent16". - * @requires_gles30 %Extension @es_extension{OES,depth_texture} or - * @es_extension{ANGLE,depth_texture} - */ - DepthComponent = GL_DEPTH_COMPONENT, - - /** - * Depth and stencil component, size implementation-dependent. - * @deprecated Prefer to use exactly specified version of this - * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::Depth24Stencil8". - * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} - */ - #ifndef MAGNUM_TARGET_GLES2 - DepthStencil = GL_DEPTH_STENCIL, - #else - DepthStencil = GL_DEPTH_STENCIL_OES, - #endif - - /** - * Depth component, 16bit. - * @requires_gles30 %Extension (@es_extension{OES,required_internalformat} - * and @es_extension{OES,depth_texture}) or (@es_extension{EXT,texture_storage} - * and @es_extension{ANGLE,depth_texture}) - */ - DepthComponent16 = GL_DEPTH_COMPONENT16, - - /** - * Depth component, 24bit. - * @requires_gles30 %Extension @es_extension{OES,required_internalformat}, - * @es_extension{OES,depth_texture} and @es_extension{OES,depth24} - */ - #ifndef MAGNUM_TARGET_GLES2 - DepthComponent24 = GL_DEPTH_COMPONENT24, - #else - DepthComponent24 = GL_DEPTH_COMPONENT24_OES, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * Depth component, 32bit. - * @requires_es_extension %Extension (@es_extension{OES,required_internalformat}, - * @es_extension{OES,depth_texture} and @es_extension{OES,depth32}) - * or (@es_extension{EXT,texture_storage} and @es_extension{ANGLE,depth_texture}) - */ - #ifndef MAGNUM_TARGET_GLES2 - DepthComponent32 = GL_DEPTH_COMPONENT32, - #else - DepthComponent32 = GL_DEPTH_COMPONENT32_OES, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Depth component, 32bit float. - * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 Only integral depth textures are available in - * OpenGL ES 2.0. - */ - DepthComponent32F = GL_DEPTH_COMPONENT32F, - #endif - - /** - * 24bit depth and 8bit stencil component. - * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} - * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} - * and (@es_extension{OES,required_internalformat} or - * (@es_extension{EXT,texture_storage} and @es_extension{ANGLE,depth_texture})) - */ - #ifdef MAGNUM_TARGET_GLES2 - Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES - #else - Depth24Stencil8 = GL_DEPTH24_STENCIL8, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * 32bit float depth component and 8bit stencil component. - * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 Only integral depth textures are available in - * OpenGL ES 2.0. - */ - Depth32FStencil8 = GL_DEPTH32F_STENCIL8 - #endif - }; - /** * @brief Max supported layer count * @@ -1227,73 +408,73 @@ class MAGNUM_EXPORT AbstractTexture { static MAGNUM_LOCAL MipmapImplementation mipmapImplementation; #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*Storage1DImplementation)(GLenum, GLsizei, InternalFormat, const Math::Vector<1, GLsizei>&); - void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size); - void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size); + typedef void(AbstractTexture::*Storage1DImplementation)(GLenum, GLsizei, TextureFormat, const Math::Vector<1, GLsizei>&); + void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); + void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); static Storage1DImplementation storage1DImplementation; #endif - typedef void(AbstractTexture::*Storage2DImplementation)(GLenum, GLsizei, InternalFormat, const Vector2i&); - void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, InternalFormat internalFormat, const Vector2i& size); + typedef void(AbstractTexture::*Storage2DImplementation)(GLenum, GLsizei, TextureFormat, const Vector2i&); + void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, InternalFormat internalFormat, const Vector2i& size); + void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #endif static Storage2DImplementation storage2DImplementation; - typedef void(AbstractTexture::*Storage3DImplementation)(GLenum, GLsizei, InternalFormat, const Vector3i&); - void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, InternalFormat internalFormat, const Vector3i& size); + typedef void(AbstractTexture::*Storage3DImplementation)(GLenum, GLsizei, TextureFormat, const Vector3i&); + void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, InternalFormat internalFormat, const Vector3i& size); + void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #endif static Storage3DImplementation storage3DImplementation; #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*GetImageImplementation)(GLenum, GLint, AbstractImage::Format, AbstractImage::Type, std::size_t, GLvoid*); - void MAGNUM_LOCAL getImageImplementationDefault(GLenum target, GLint level, AbstractImage::Format format, AbstractImage::Type type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationDSA(GLenum target, GLint level, AbstractImage::Format format, AbstractImage::Type type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, AbstractImage::Format format, AbstractImage::Type type, std::size_t dataSize, GLvoid* data); + typedef void(AbstractTexture::*GetImageImplementation)(GLenum, GLint, ImageFormat, ImageType, std::size_t, GLvoid*); + void MAGNUM_LOCAL getImageImplementationDefault(GLenum target, GLint level, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationDSA(GLenum target, GLint level, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, ImageFormat format, ImageType type, std::size_t dataSize, GLvoid* data); static MAGNUM_LOCAL GetImageImplementation getImageImplementation; #endif #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*Image1DImplementation)(GLenum, GLint, InternalFormat, const Math::Vector<1, GLsizei>&, AbstractImage::Format, AbstractImage::Type, const GLvoid*); - void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + typedef void(AbstractTexture::*Image1DImplementation)(GLenum, GLint, TextureFormat, const Math::Vector<1, GLsizei>&, ImageFormat, ImageType, const GLvoid*); + void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); static Image1DImplementation image1DImplementation; #endif - typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, InternalFormat, const Vector2i&, AbstractImage::Format, AbstractImage::Type, const GLvoid*); - void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + typedef void(AbstractTexture::*Image2DImplementation)(GLenum, GLint, TextureFormat, const Vector2i&, ImageFormat, ImageType, const GLvoid*); + void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); #endif static Image2DImplementation image2DImplementation; - typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, InternalFormat, const Vector3i&, AbstractImage::Format, AbstractImage::Type, const GLvoid*); - void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + typedef void(AbstractTexture::*Image3DImplementation)(GLenum, GLint, TextureFormat, const Vector3i&, ImageFormat, ImageType, const GLvoid*); + void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); #endif static Image3DImplementation image3DImplementation; #ifndef MAGNUM_TARGET_GLES - typedef void(AbstractTexture::*SubImage1DImplementation)(GLenum, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, AbstractImage::Format, AbstractImage::Type, const GLvoid*); - void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + typedef void(AbstractTexture::*SubImage1DImplementation)(GLenum, GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, ImageFormat, ImageType, const GLvoid*); + void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ImageFormat format, ImageType type, const GLvoid* data); static SubImage1DImplementation subImage1DImplementation; #endif - typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Vector2i&, const Vector2i&, AbstractImage::Format, AbstractImage::Type, const GLvoid*); - void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + typedef void(AbstractTexture::*SubImage2DImplementation)(GLenum, GLint, const Vector2i&, const Vector2i&, ImageFormat, ImageType, const GLvoid*); + void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ImageFormat format, ImageType type, const GLvoid* data); #endif static SubImage2DImplementation subImage2DImplementation; - typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Vector3i&, const Vector3i&, AbstractImage::Format, AbstractImage::Type, const GLvoid*); - void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + typedef void(AbstractTexture::*SubImage3DImplementation)(GLenum, GLint, const Vector3i&, const Vector3i&, ImageFormat, ImageType, const GLvoid*); + void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ImageFormat format, ImageType type, const GLvoid* data); #endif static SubImage3DImplementation subImage3DImplementation; @@ -1349,11 +530,11 @@ template<> struct AbstractTexture::DataHelper<1> { (texture->*parameteriImplementation)(GL_TEXTURE_WRAP_S, static_cast(wrapping.x())); } - inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size) { + inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { (texture->*storage1DImplementation)(target, levels, internalFormat, size); } - template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, InternalFormat internalFormat, Image* image) { + template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { (texture->*image1DImplementation)(target, level, internalFormat, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } @@ -1384,11 +565,11 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { static void setWrapping(AbstractTexture* texture, const Array2D& wrapping); - inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, InternalFormat internalFormat, const Vector2i& size) { + inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { (texture->*storage2DImplementation)(target, levels, internalFormat, size); } - template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, InternalFormat internalFormat, Image* image) { + template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { (texture->*image2DImplementation)(target, level, internalFormat, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } @@ -1422,11 +603,11 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { static void setWrapping(AbstractTexture* texture, const Array3D& wrapping); - inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, InternalFormat internalFormat, const Vector3i& size) { + inline static void setStorage(AbstractTexture* texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { (texture->*storage3DImplementation)(target, levels, internalFormat, size); } - template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, InternalFormat internalFormat, Image* image) { + template inline static typename std::enable_if::type setImage(AbstractTexture* texture, GLenum target, GLint level, TextureFormat internalFormat, Image* image) { (texture->*image3DImplementation)(target, level, internalFormat, image->size(), image->format(), image->type(), Implementation::ImageHelper::dataOrPixelUnpackBuffer(image)); } diff --git a/src/BufferImage.cpp b/src/BufferImage.cpp index 65666f033..4de6bbb6c 100644 --- a/src/BufferImage.cpp +++ b/src/BufferImage.cpp @@ -27,7 +27,7 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES2 -template void BufferImage::setData(const typename DimensionTraits::VectorType& size, Format format, Type type, const GLvoid* data, Buffer::Usage usage) { +template void BufferImage::setData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, const void* data, Buffer::Usage usage) { _format = format; _type = type; _size = size; diff --git a/src/BufferImage.h b/src/BufferImage.h index ae4910eca..3e2436201 100644 --- a/src/BufferImage.h +++ b/src/BufferImage.h @@ -58,7 +58,7 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac * Dimensions and buffer are empty, call setData() to fill the image * with data. */ - inline explicit BufferImage(Format format, Type type): AbstractImage(format, type) { + inline explicit BufferImage(ImageFormat format, ImageType type): AbstractImage(format, type) { _buffer.setTargetHint(Buffer::Target::PixelPack); } @@ -81,7 +81,7 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac * * @see Buffer::setData() */ - void setData(const typename DimensionTraits::VectorType& size, Format format, Type type, const GLvoid* data, Buffer::Usage usage); + void setData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, const void* data, Buffer::Usage usage); private: Math::Vector _size; diff --git a/src/BufferTexture.cpp b/src/BufferTexture.cpp index c06e62ec6..55231f970 100644 --- a/src/BufferTexture.cpp +++ b/src/BufferTexture.cpp @@ -43,24 +43,23 @@ void BufferTexture::initializeContextBasedFunctionality(Context* context) { } } -void BufferTexture::setBufferImplementationDefault(InternalFormat internalFormat, Buffer* buffer) { +void BufferTexture::setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer) { bindInternal(); glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); } -void BufferTexture::setBufferImplementationDSA(InternalFormat internalFormat, Buffer* buffer) { +void BufferTexture::setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer) { glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); } -void BufferTexture::setBufferRangeImplementationDefault(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { +void BufferTexture::setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { bindInternal(); glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); } -void BufferTexture::setBufferRangeImplementationDSA(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { +void BufferTexture::setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); } - } #endif diff --git a/src/BufferTexture.h b/src/BufferTexture.h index 38adaa430..c631344f5 100644 --- a/src/BufferTexture.h +++ b/src/BufferTexture.h @@ -26,7 +26,7 @@ #ifndef MAGNUM_TARGET_GLES /** @file - * @brief Class Magnum::BufferTexture + * @brief Class Magnum::BufferTexture, enum Magnum::BufferTextureFormat */ #endif @@ -56,7 +56,7 @@ Example usage: @code Buffer* buffer; BufferTexture texture; -texture.setBuffer(buffer); +texture.setBuffer(BufferTextureFormat::RGB32F, buffer); constexpr static Vector3 data[] = { // ... @@ -88,121 +88,6 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture { BufferTexture& operator=(BufferTexture&&) = delete; public: - /** - * @brief Internal format - * - * @see setBuffer() - */ - enum class InternalFormat: GLenum { - /** Red component, normalized unsigned byte. */ - R8 = GL_R8, - - /** Red and green component, each normalized unsigned byte. */ - RG8 = GL_RG8, - - /** RGBA, each component normalized unsigned byte. */ - RGBA8 = GL_RGBA8, - - /** Red component, normalized unsigned short. */ - R16 = GL_R16, - - /** Red and green component, each normalized unsigned short. */ - RG16 = GL_RG16, - - /** RGBA, each component normalized unsigned short. */ - RGBA16 = GL_RGBA16, - - /** Red component, non-normalized unsigned byte. */ - R8UI = GL_R8UI, - - /** Red and green component, each non-normalized unsigned byte. */ - RG8UI = GL_RG8UI, - - /** RGBA, each component non-normalized unsigned byte. */ - RGBA8UI = GL_RGBA8UI, - - /** Red component, non-normalized signed byte. */ - R8I = GL_R8I, - - /** Red and green component, each non-normalized signed byte. */ - RG8I = GL_RG8I, - - /** RGBA, each component non-normalized signed byte. */ - RGBA8I = GL_RGBA8I, - - /** Red component, non-normalized unsigned short. */ - R16UI = GL_R16UI, - - /** Red and green component, each non-normalized unsigned short. */ - RG16UI = GL_RG16UI, - - /** RGBA, each component non-normalized unsigned short. */ - RGBA16UI = GL_RGBA16UI, - - /** Red component, non-normalized signed short. */ - R16I = GL_R16I, - - /** Red and green component, each non-normalized signed short. */ - RG16I = GL_RG16I, - - /** RGBA, each component non-normalized signed short. */ - RGBA16I = GL_RGBA16I, - - /** Red component, non-normalized unsigned int. */ - R32UI = GL_R32UI, - - /** Red and green component, each non-normalized unsigned int. */ - RG32UI = GL_RG32UI, - - /** - * RGB, each component non-normalized unsigned int. - * @requires_gl40 %Extension @extension{ARB,texture_buffer_object_rgb32} - */ - RGB32UI = GL_RGB32UI, - - /** RGBA, each component non-normalized unsigned int. */ - RGBA32UI = GL_RGBA32UI, - - /** Red component, non-normalized signed int. */ - R32I = GL_R32I, - - /** Red and green component, each non-normalized signed int. */ - RG32I = GL_RG32I, - - /** - * RGB, each component non-normalized signed int. - * @requires_gl40 %Extension @extension{ARB,texture_buffer_object_rgb32} - */ - RGB32I = GL_RGB32I, - - /** RGBA, each component non-normalized signed int. */ - RGBA32I = GL_RGBA32I, - - /** Red component, half float. */ - R16F = GL_R16F, - - /** Red and green component, each half float. */ - RG16F = GL_RG16F, - - /** RGBA, each component half float. */ - RGBA16F = GL_RGBA16F, - - /** Red component, float. */ - R32F = GL_R32F, - - /** Red and green component, each float. */ - RG32F = GL_RG32F, - - /** - * RGB, each component float. - * @requires_gl40 %Extension @extension{ARB,texture_buffer_object_rgb32} - */ - RGB32F = GL_RGB32F, - - /** RGBA, each component float. */ - RGBA32F = GL_RGBA32F - }; - inline explicit BufferTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {} /** @copydoc AbstractTexture::bind() */ @@ -219,7 +104,7 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture { * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer} * or @fn_gl_extension{TextureBuffer,EXT,direct_state_access} */ - inline void setBuffer(InternalFormat internalFormat, Buffer* buffer) { + inline void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer) { (this->*setBufferImplementation)(internalFormat, buffer); } @@ -237,24 +122,139 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture { * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer} * or @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} */ - inline void setBuffer(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { + inline void setBuffer(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { (this->*setBufferRangeImplementation)(internalFormat, buffer, offset, size); } private: static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); - typedef void(BufferTexture::*SetBufferImplementation)(InternalFormat, Buffer*); - void MAGNUM_LOCAL setBufferImplementationDefault(InternalFormat internalFormat, Buffer* buffer); - void MAGNUM_LOCAL setBufferImplementationDSA(InternalFormat internalFormat, Buffer* buffer); + typedef void(BufferTexture::*SetBufferImplementation)(BufferTextureFormat, Buffer*); + void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer); + void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer); static SetBufferImplementation setBufferImplementation; - typedef void(BufferTexture::*SetBufferRangeImplementation)(InternalFormat, Buffer*, GLintptr, GLsizeiptr); - void MAGNUM_LOCAL setBufferRangeImplementationDefault(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); - void MAGNUM_LOCAL setBufferRangeImplementationDSA(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); + typedef void(BufferTexture::*SetBufferRangeImplementation)(BufferTextureFormat, Buffer*, GLintptr, GLsizeiptr); + void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); + void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); static SetBufferRangeImplementation setBufferRangeImplementation; }; +/** +@brief Internal buffer texture format + +@see BufferTexture +*/ +enum class BufferTextureFormat: GLenum { + /** Red component, normalized unsigned byte. */ + R8 = GL_R8, + + /** Red and green component, each normalized unsigned byte. */ + RG8 = GL_RG8, + + /** RGBA, each component normalized unsigned byte. */ + RGBA8 = GL_RGBA8, + + /** Red component, normalized unsigned short. */ + R16 = GL_R16, + + /** Red and green component, each normalized unsigned short. */ + RG16 = GL_RG16, + + /** RGBA, each component normalized unsigned short. */ + RGBA16 = GL_RGBA16, + + /** Red component, non-normalized unsigned byte. */ + R8UI = GL_R8UI, + + /** Red and green component, each non-normalized unsigned byte. */ + RG8UI = GL_RG8UI, + + /** RGBA, each component non-normalized unsigned byte. */ + RGBA8UI = GL_RGBA8UI, + + /** Red component, non-normalized signed byte. */ + R8I = GL_R8I, + + /** Red and green component, each non-normalized signed byte. */ + RG8I = GL_RG8I, + + /** RGBA, each component non-normalized signed byte. */ + RGBA8I = GL_RGBA8I, + + /** Red component, non-normalized unsigned short. */ + R16UI = GL_R16UI, + + /** Red and green component, each non-normalized unsigned short. */ + RG16UI = GL_RG16UI, + + /** RGBA, each component non-normalized unsigned short. */ + RGBA16UI = GL_RGBA16UI, + + /** Red component, non-normalized signed short. */ + R16I = GL_R16I, + + /** Red and green component, each non-normalized signed short. */ + RG16I = GL_RG16I, + + /** RGBA, each component non-normalized signed short. */ + RGBA16I = GL_RGBA16I, + + /** Red component, non-normalized unsigned int. */ + R32UI = GL_R32UI, + + /** Red and green component, each non-normalized unsigned int. */ + RG32UI = GL_RG32UI, + + /** + * RGB, each component non-normalized unsigned int. + * @requires_gl40 %Extension @extension{ARB,texture_buffer_object_rgb32} + */ + RGB32UI = GL_RGB32UI, + + /** RGBA, each component non-normalized unsigned int. */ + RGBA32UI = GL_RGBA32UI, + + /** Red component, non-normalized signed int. */ + R32I = GL_R32I, + + /** Red and green component, each non-normalized signed int. */ + RG32I = GL_RG32I, + + /** + * RGB, each component non-normalized signed int. + * @requires_gl40 %Extension @extension{ARB,texture_buffer_object_rgb32} + */ + RGB32I = GL_RGB32I, + + /** RGBA, each component non-normalized signed int. */ + RGBA32I = GL_RGBA32I, + + /** Red component, half float. */ + R16F = GL_R16F, + + /** Red and green component, each half float. */ + RG16F = GL_RG16F, + + /** RGBA, each component half float. */ + RGBA16F = GL_RGBA16F, + + /** Red component, float. */ + R32F = GL_R32F, + + /** Red and green component, each float. */ + RG32F = GL_RG32F, + + /** + * RGB, each component float. + * @requires_gl40 %Extension @extension{ARB,texture_buffer_object_rgb32} + */ + RGB32F = GL_RGB32F, + + /** RGBA, each component float. */ + RGBA32F = GL_RGBA32F +}; + } #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 436453b6d..300f43838 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,7 @@ set(Magnum_SRCS DefaultFramebuffer.cpp Framebuffer.cpp Image.cpp + ImageFormat.cpp Mesh.cpp OpenGL.cpp Query.cpp @@ -110,18 +111,21 @@ set(Magnum_HEADERS Extensions.h Framebuffer.h Image.h + ImageFormat.h ImageWrapper.h Magnum.h Mesh.h OpenGL.h Query.h Renderbuffer.h + RenderbufferFormat.h Renderer.h Resource.h ResourceManager.h Shader.h Swizzle.h Texture.h + TextureFormat.h Timeline.h Types.h diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index d1be4b86c..6f7e22056 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -54,13 +54,13 @@ See Texture documentation for introduction. Common usage is to fully configure all texture parameters and then set the data from e.g. set of Image objects: @code -Image2D positiveX({256, 256}, Image2D::Components::RGBA, Image2D::ComponentType::UnsignedByte, dataPositiveX); +Image2D positiveX({256, 256}, ImageFormat::RGBA, ImageType::UnsignedByte, dataPositiveX); // ... CubeMapTexture texture; texture.setMagnificationFilter(Texture2D::Filter::Linear) // ... - ->setStorage(Math::log2(256)+1, Texture2D::Format::RGBA8, {256, 256}) + ->setStorage(Math::log2(256)+1, TextureFormat::RGBA8, {256, 256}) ->setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, &positiveX) ->setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, &negativeX) // ... @@ -124,7 +124,7 @@ class CubeMapTexture: public AbstractTexture { * * See Texture::setStorage() for more information. */ - inline CubeMapTexture* setStorage(Int levels, InternalFormat internalFormat, const Vector2i& size) { + inline CubeMapTexture* setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) { DataHelper<2>::setStorage(this, _target, levels, internalFormat, size); return this; } @@ -170,7 +170,7 @@ class CubeMapTexture: public AbstractTexture { * * See Texture::setImage() for more information. */ - template inline CubeMapTexture* setImage(Coordinate coordinate, Int level, InternalFormat internalFormat, Image* image) { + template inline CubeMapTexture* setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, Image* image) { DataHelper<2>::setImage(this, static_cast(coordinate), level, internalFormat, image); return this; } diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index b39a50f92..3e7d52594 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -48,16 +48,16 @@ calling setStorage() or by passing properly sized empty Image to setImage(). Example: array with 16 layers of cube map faces, each face consisting of six 64x64 images: @code -Image3D dummy({64, 64, 16*6}, Image3D::Components::RGBA, Image3D::ComponentType::UnsignedByte, nullptr); +Image3D dummy({64, 64, 16*6}, ImageFormat::RGBA, ImageType::UnsignedByte, nullptr); CubeMapTextureArray texture; texture.setMagnificationFilter(CubeMapTextureArray::Filter::Linear) // ... - ->setStorage(Math::log2(64)+1, CubeMapTextureArray::Format::RGBA8, {64, 64, 16}); + ->setStorage(Math::log2(64)+1, TextureFormat::RGBA8, {64, 64, 16}); for(std::size_t i = 0; i != 16; ++i) { void* dataPositiveX = ...; - Image2D imagePositiveX({64, 64}, Image3D::Components::RGBA, Image3D::ComponentType::UnsignedByte, imagePositiveX); + Image2D imagePositiveX({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, imagePositiveX); // ... texture->setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX); texture->setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); @@ -124,7 +124,7 @@ class CubeMapTextureArray: public AbstractTexture { * * See Texture::setStorage() for more information. */ - inline CubeMapTextureArray* setStorage(Int levels, InternalFormat internalFormat, const Vector3i& size) { + inline CubeMapTextureArray* setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) { DataHelper<3>::setStorage(this, _target, levels, internalFormat, size); return this; } @@ -173,7 +173,7 @@ class CubeMapTextureArray: public AbstractTexture { * * See Texture::setImage() for more information. */ - template inline CubeMapTextureArray* setImage(Int level, InternalFormat internalFormat, T* image) { + template inline CubeMapTextureArray* setImage(Int level, TextureFormat internalFormat, T* image) { DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image); return this; } diff --git a/src/Image.cpp b/src/Image.cpp index 68a85c0e2..71c5b1a7c 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -26,7 +26,7 @@ namespace Magnum { -template void Image::setData(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data) { +template void Image::setData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data) { delete[] _data; _format = format; _type = type; diff --git a/src/Image.h b/src/Image.h index 8c1649b9d..8c7055f63 100644 --- a/src/Image.h +++ b/src/Image.h @@ -55,7 +55,7 @@ template class Image: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline explicit Image(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + inline explicit Image(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -65,7 +65,7 @@ template class Image: public AbstractImage { * Dimensions and data pointer are set to zero, call setData() to fill * the image with data. */ - inline explicit Image(Format format, Type type): AbstractImage(format, type), _data(nullptr) {} + inline explicit Image(ImageFormat format, ImageType type): AbstractImage(format, type), _data(nullptr) {} /** @brief Destructor */ inline ~Image() { delete[] _data; } @@ -87,7 +87,7 @@ template class Image: public AbstractImage { * Deletes previous data and replaces them with new. Note that the * data are not copied, but they are deleted on destruction. */ - void setData(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data); + void setData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data); private: Math::Vector _size; diff --git a/src/ImageFormat.cpp b/src/ImageFormat.cpp new file mode 100644 index 000000000..014cf25eb --- /dev/null +++ b/src/ImageFormat.cpp @@ -0,0 +1,128 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "ImageFormat.h" + +#include + +namespace Magnum { + +#ifndef DOXYGEN_GENERATING_OUTPUT +Debug operator<<(Debug debug, ImageFormat value) { + switch(value) { + #define _c(value) case ImageFormat::value: return debug << "ImageFormat::" #value; + _c(Red) + #ifndef MAGNUM_TARGET_GLES + _c(Green) + _c(Blue) + #endif + _c(RG) + _c(RGB) + _c(RGBA) + #ifndef MAGNUM_TARGET_GLES + _c(BGR) + #endif + #ifndef MAGNUM_TARGET_GLES3 + _c(BGRA) + #endif + #ifndef MAGNUM_TARGET_GLES2 + _c(RedInteger) + #ifndef MAGNUM_TARGET_GLES + _c(GreenInteger) + _c(BlueInteger) + #endif + _c(RGInteger) + _c(RGBInteger) + _c(RGBAInteger) + #ifndef MAGNUM_TARGET_GLES + _c(BGRInteger) + _c(BGRAInteger) + #endif + #endif + _c(DepthComponent) + #ifndef MAGNUM_TARGET_GLES3 + _c(StencilIndex) + #endif + _c(DepthStencil) + #undef _c + } + + return debug << "ImageFormat::(invalid)"; +} + +Debug operator<<(Debug debug, ImageType value) { + switch(value) { + #define _c(value) case ImageType::value: return debug << "ImageType::" #value; + _c(UnsignedByte) + #ifndef MAGNUM_TARGET_GLES2 + _c(Byte) + #endif + _c(UnsignedShort) + #ifndef MAGNUM_TARGET_GLES2 + _c(Short) + #endif + _c(UnsignedInt) + #ifndef MAGNUM_TARGET_GLES2 + _c(Int) + #endif + _c(HalfFloat) + _c(Float) + #ifndef MAGNUM_TARGET_GLES + _c(UnsignedByte332) + _c(UnsignedByte233Rev) + #endif + _c(UnsignedShort565) + #ifndef MAGNUM_TARGET_GLES + _c(UnsignedShort565Rev) + #endif + _c(UnsignedShort4444) + #ifndef MAGNUM_TARGET_GLES3 + _c(UnsignedShort4444Rev) + #endif + _c(UnsignedShort5551) + #ifndef MAGNUM_TARGET_GLES3 + _c(UnsignedShort1555Rev) + #endif + #ifndef MAGNUM_TARGET_GLES + _c(UnsignedInt8888) + _c(UnsignedInt8888Rev) + _c(UnsignedInt1010102) + #endif + _c(UnsignedInt2101010Rev) + #ifndef MAGNUM_TARGET_GLES2 + _c(UnsignedInt10F11F11FRev) + _c(UnsignedInt5999Rev) + #endif + _c(UnsignedInt248) + #ifndef MAGNUM_TARGET_GLES2 + _c(Float32UnsignedInt248Rev) + #endif + #undef _c + } + + return debug << "ImageType::(invalid)"; +} +#endif + +} diff --git a/src/ImageFormat.h b/src/ImageFormat.h new file mode 100644 index 000000000..23b2a58f8 --- /dev/null +++ b/src/ImageFormat.h @@ -0,0 +1,454 @@ +#ifndef Magnum_ImageFormat_h +#define Magnum_ImageFormat_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Enum Magnum::ImageFormat, Magnum::ImageType + */ + +#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, ImageWrapper, BufferImage, Trade::ImageData +*/ +enum class ImageFormat: GLenum { + /** + * Floating-point red channel. + * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg}. + * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg}. + */ + #ifndef MAGNUM_TARGET_GLES2 + Red = GL_RED, + #else + Red = GL_RED_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Floating-point green channel. + * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::Red" is + * available in OpenGL ES. + */ + Green = GL_GREEN, + + /** + * Floating-point blue channel. + * @requires_gl Only @ref Magnum::ImageFormat "ImageFormat::Red" is + * available in OpenGL ES. + */ + Blue = GL_BLUE, + + /** @todo GL_ALPHA? */ + #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 + + /** + * 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. For framebuffer reading only. + * @requires_es_extension %Extension @es_extension2{NV,read_stencil,GL_NV_read_depth_stencil} + * @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{EXT,packed_depth_stencil} + * @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, ImageWrapper, BufferImage, Trade::ImageData + */ +enum class ImageType: GLenum { + /** Each component unsigned byte. */ + UnsignedByte = GL_UNSIGNED_BYTE, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Each component signed byte. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, only @ref Magnum::ImageType "ImageType::UnsignedByte" + * is available in OpenGL ES 2.0. + */ + Byte = GL_BYTE, + #endif + + /** + * Each component unsigned short. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} + * or @es_extension{ANGLE,depth_texture}. + */ + UnsignedShort = GL_UNSIGNED_SHORT, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Each component signed short. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gles30 For texture data only, only @ref Magnum::ImageType "ImageType::UnsignedShort" + * is available in OpenGL ES 2.0. + */ + Short = GL_SHORT, + #endif + + /** + * Each component unsigned int. + * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. + * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} + * or @es_extension{ANGLE,depth_texture}. + */ + UnsignedInt = GL_UNSIGNED_INT, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Each component signed int. + * @requires_gles30 Only @ref Magnum::ImageType "ImageType::UnsignedInt" + * is available in OpenGL ES 2.0. + */ + Int = GL_INT, + #endif + + /** + * Each component half float. + * @requires_gl30 %Extension @extension{NV,half_float} / @extension{ARB,half_float_pixel} + * @requires_gles30 For texture data only, extension + * @es_extension2{OES,texture_half_float,OES_texture_float}. + */ + #ifndef MAGNUM_TARGET_GLES2 + HalfFloat = GL_HALF_FLOAT, + #else + HalfFloat = GL_HALF_FLOAT_OES, + #endif + + /** + * Each component float. + * @requires_gles30 For texture data only, extension @es_extension{OES,texture_float}. + */ + Float = GL_FLOAT, + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, unsigned byte, red and green component 3bit, blue component 2bit. + * @requires_gl Packed 12bit types are not available in OpenGL ES. + */ + UnsignedByte332 = GL_UNSIGNED_BYTE_3_3_2, + + /** + * BGR, unsigned byte, red and green component 3bit, blue component 2bit. + * @requires_gl Packed 12bit types are not available in OpenGL ES. + */ + UnsignedByte233Rev = GL_UNSIGNED_BYTE_2_3_3_REV, + #endif + + /** + * RGB, unsigned byte, red and blue component 5bit, green 6bit. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + UnsignedShort565 = GL_UNSIGNED_SHORT_5_6_5, + + #ifndef MAGNUM_TARGET_GLES + /** + * BGR, unsigned short, red and blue 5bit, green 6bit. + * @requires_gl Only @ref Magnum::ImageType "ImageType::RGB565" is + * available in OpenGL ES. + */ + UnsignedShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV, + #endif + + /** + * RGBA, unsigned short, each component 4bit. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + UnsignedShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, + + #ifndef MAGNUM_TARGET_GLES3 + /** + * ABGR, unsigned short, each component 4bit. + * @requires_es_extension For framebuffer reading only, extension + * @es_extension{EXT,read_format_bgra}. + */ + #ifndef MAGNUM_TARGET_GLES + UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV, + #else + UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, + #endif + #endif + + /** + * RGBA, unsigned short, each RGB component 5bit, alpha component 1bit. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + */ + UnsignedShort5551 = GL_UNSIGNED_SHORT_5_5_5_1, + + #ifndef MAGNUM_TARGET_GLES3 + /** + * ABGR, unsigned short, each RGB component 5bit, alpha component 1bit. + * @requires_es_extension For framebuffer reading only, extension + * @es_extension{EXT,read_format_bgra}. + */ + #ifndef MAGNUM_TARGET_GLES + UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV, + #else + UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * RGBA, unsigned int, each component 8bit. + * @requires_gl Use @ref Magnum::ImageType "ImageType::UnsignedByte" in + * OpenGL ES instead. + */ + UnsignedInt8888 = GL_UNSIGNED_INT_8_8_8_8, + + /** + * ABGR, unsigned int, each component 8bit. + * @requires_gl Only RGBA component ordering is available in OpenGL ES, see + * @ref Magnum::ImageType "ImageType::UnsignedInt8888" for more + * information. + */ + UnsignedInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV, + + /** + * RGBA, unsigned int, each RGB component 10bit, alpha component 2bit. + * @requires_gl Only @ref Magnum::ImageType "ImageType::UnsignedInt2101010Rev" + * is available in OpenGL ES. + */ + UnsignedInt1010102 = GL_UNSIGNED_INT_10_10_10_2, + #endif + + /** + * ABGR, unsigned int, each RGB component 10bit, alpha component 2bit. + * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. + * @requires_gles30 For texture data only, extension + * @es_extension{EXT,texture_type_2_10_10_10_REV}. + */ + #ifndef MAGNUM_TARGET_GLES2 + UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV, + #else + UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * BGR, unsigned int, red and green 11bit float, blue 10bit float. + * @requires_gl30 %Extension @extension{EXT,packed_float} + * @requires_gles30 Floating-point types are not available in OpenGL ES + * 2.0. + */ + UnsignedInt10F11F11FRev = GL_UNSIGNED_INT_10F_11F_11F_REV, + + /** + * BGR, unsigned int, each component 9bit + 5bit exponent. + * @requires_gl30 %Extension @extension{EXT,texture_shared_exponent} + * @requires_gles30 Only 8bit and 16bit types are available in OpenGL ES + * 2.0. + */ + UnsignedInt5999Rev = GL_UNSIGNED_INT_5_9_9_9_REV, + #endif + + /** + * Unsigned int, depth component 24bit, stencil index 8bit. + * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} + * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil}. + */ + #ifdef MAGNUM_TARGET_GLES2 + UnsignedInt248 = GL_UNSIGNED_INT_24_8_OES + #else + UnsignedInt248 = GL_UNSIGNED_INT_24_8, + + /** + * 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); + +} + +#endif diff --git a/src/ImageWrapper.h b/src/ImageWrapper.h index e9e0b7f1d..bc0f87beb 100644 --- a/src/ImageWrapper.h +++ b/src/ImageWrapper.h @@ -62,7 +62,7 @@ template class ImageWrapper: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline explicit ImageWrapper(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + inline explicit ImageWrapper(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -73,7 +73,7 @@ template class ImageWrapper: public AbstractImage { * Data pointer is set to zero, call setData() to fill the image with * data. */ - inline explicit ImageWrapper(const typename DimensionTraits::VectorType& size, Format format, Type type): AbstractImage(format, type), _size(size), _data(nullptr) {} + inline explicit ImageWrapper(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type): AbstractImage(format, type), _size(size), _data(nullptr) {} /** @brief %Image size */ inline typename DimensionTraits::VectorType size() const { return _size; } @@ -90,7 +90,7 @@ template class ImageWrapper: public AbstractImage { * passed in constructor. The data are not copied nor deleted on * destruction. */ - inline void setData(GLvoid* data) { + inline void setData(void* data) { _data = reinterpret_cast(data); } diff --git a/src/Magnum.h b/src/Magnum.h index b7fa78991..47b1870bc 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -34,6 +34,10 @@ #include "Types.h" #include "magnumConfigure.h" +#ifndef DOXYGEN_GENERATING_OUTPUT +typedef unsigned int GLenum; /* Needed for *Format and *Type enums */ +#endif + namespace Corrade { namespace Utility { class Debug; @@ -346,6 +350,7 @@ typedef BufferImage<3> BufferImage3D; #ifndef MAGNUM_TARGET_GLES class BufferTexture; +enum class BufferTextureFormat: GLenum; #endif template class Color3; @@ -371,6 +376,9 @@ typedef Image<1> Image1D; typedef Image<2> Image2D; typedef Image<3> Image3D; +enum class ImageFormat: GLenum; +enum class ImageType: GLenum; + template class ImageWrapper; typedef ImageWrapper<1> ImageWrapper1D; typedef ImageWrapper<2> ImageWrapper2D; @@ -384,6 +392,7 @@ class SampleQuery; class TimeQuery; class Renderbuffer; +enum class RenderbufferFormat: GLenum; enum class ResourceState: UnsignedByte; enum class ResourceDataState: UnsignedByte; @@ -401,6 +410,8 @@ typedef Texture<1> Texture1D; typedef Texture<2> Texture2D; typedef Texture<3> Texture3D; +enum class TextureFormat: GLenum; + class Timeline; #endif diff --git a/src/Renderbuffer.cpp b/src/Renderbuffer.cpp index 0ca1a724c..6baba9d13 100644 --- a/src/Renderbuffer.cpp +++ b/src/Renderbuffer.cpp @@ -63,13 +63,13 @@ void Renderbuffer::initializeContextBasedFunctionality(Context* context) { #endif } -void Renderbuffer::storageImplementationDefault(Renderbuffer::InternalFormat internalFormat, const Vector2i& size) { +void Renderbuffer::storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size) { bind(); glRenderbufferStorage(GL_RENDERBUFFER, GLenum(internalFormat), size.x(), size.y()); } #ifndef MAGNUM_TARGET_GLES -void Renderbuffer::storageImplementationDSA(Renderbuffer::InternalFormat internalFormat, const Vector2i& size) { +void Renderbuffer::storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size) { glNamedRenderbufferStorageEXT(_id, GLenum(internalFormat), size.x(), size.y()); } #endif diff --git a/src/Renderbuffer.h b/src/Renderbuffer.h index 58f1bcd3e..0ae8f24e8 100644 --- a/src/Renderbuffer.h +++ b/src/Renderbuffer.h @@ -60,476 +60,6 @@ class MAGNUM_EXPORT Renderbuffer { Renderbuffer& operator=(Renderbuffer&&) = delete; public: - /** - * @brief Internal format - * - * @see setStorage() - * @todo RGB, RGB8 ES only (ES3 + @es_extension{OES,rgb8_rgba8}) - */ - enum class InternalFormat: GLenum { - #ifndef MAGNUM_TARGET_GLES - /** - * Red component, normalized unsigned, size implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::R8". - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Use exactly specified format in OpenGL ES instead. - */ - Red = GL_RED, - #endif - - /** - * Red component, normalized unsigned byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gles30 %Extension @es_extension{EXT,texture_rg} - */ - #ifndef MAGNUM_TARGET_GLES2 - R8 = GL_R8, - #else - R8 = GL_R8_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Red and green component, normalized unsigned, size - * implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::RG8". - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Use exactly specified format in OpenGL ES instead. - */ - RG = GL_RG, - #endif - - /** - * Red and green component, each normalized unsigned byte. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gles30 %Extension @es_extension{EXT,texture_rg} - */ - #ifndef MAGNUM_TARGET_GLES2 - RG8 = GL_RG8, - #else - RG8 = GL_RG8_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * RGBA, normalized unsigned, size implementation-dependent. - * @deprecated Prefer to use the exactly specified version of this - * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::RGBA8". - * @requires_gl Use exactly specified format in OpenGL ES 2.0 - * instead. - */ - RGBA = GL_RGBA, - #endif - - /** - * RGBA, each component normalized unsigned byte. - * @requires_gles30 %Extension @es_extension{ARM,rgba8} or - * @es_extension{OES,rgb8_rgba8} - */ - #ifndef MAGNUM_TARGET_GLES2 - RGBA8 = GL_RGBA8, - #else - RGBA8 = GL_RGBA8_OES, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Red component, normalized unsigned short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - R16 = GL_R16, - - /** - * Red and green component, each normalized unsigned short. - * @requires_gl30 %Extension @extension{ARB,texture_rg} - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RG16 = GL_RG16, - - /** - * RGB, each component normalized unsigned short. - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RGB16 = GL_RGB16, - - /** - * RGBA, each component normalized unsigned short. - * @requires_gl Only byte-sized normalized formats are available - * in OpenGL ES. - */ - RGBA16 = GL_RGBA16, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Red component, non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R8UI = GL_R8UI, - - /** - * Red and green component, each non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG8UI = GL_RG8UI, - - /** - * RGBA, each component non-normalized unsigned byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA8UI = GL_RGBA8UI, - - /** - * Red component, non-normalized signed byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R8I = GL_R8I, - - /** - * Red and green component, each non-normalized signed byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG8I = GL_RG8I, - - /** - * RGBA, each component non-normalized signed byte. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA8I = GL_RGBA8I, - - /** - * Red component, non-normalized unsigned short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R16UI = GL_R16UI, - - /** - * Red and green component, each non-normalized unsigned short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG16UI = GL_RG16UI, - - /** - * RGBA, each component non-normalized unsigned short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA16UI = GL_RGBA16UI, - - /** - * Red component, non-normalized signed short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R16I = GL_R16I, - - /** - * Red and green component, each non-normalized signed short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG16I = GL_RG16I, - - /** - * RGBA, each component non-normalized signed short. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA16I = GL_RGBA16I, - - /** - * Red component, non-normalized unsigned int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R32UI = GL_R32UI, - - /** - * Red and green component, each non-normalized unsigned int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG32UI = GL_RG32UI, - - /** - * RGBA, each component non-normalized unsigned int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA32UI = GL_RGBA32UI, - - /** - * Red component, non-normalized signed int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - R32I = GL_R32I, - - /** - * Red and green component, each non-normalized signed int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RG32I = GL_RG32I, - - /** - * RGBA, each component non-normalized signed int. - * @requires_gl30 %Extension @extension{EXT,texture_integer} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGBA32I = GL_RGBA32I, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Red component, half float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gl Only (non)normalized integral formats are - * available in OpenGL ES. - */ - R16F = GL_R16F, - - /** - * Red and green component, each half float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gl Only (non)normalized integral formats are - * available in OpenGL ES. - */ - RG16F = GL_RG16F, - - /** - * RGBA, each component half float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gl Only (non)normalized integral formats are - * available in OpenGL ES. - */ - RGBA16F = GL_RGBA16F, - - /** - * Red component, float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gl Only (non)normalized integral formats are - * available in OpenGL ES. - */ - R32F = GL_R32F, - - /** - * Red and green component, each float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gl Only (non)normalized integral formats are - * available in OpenGL ES. - */ - RG32F = GL_RG32F, - - /** - * RGBA, each component float. - * @requires_gl30 %Extension @extension{ARB,texture_float} - * @requires_gl Only (non)normalized integral formats are - * available in OpenGL ES. - */ - RGBA32F = GL_RGBA32F, - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. - * @requires_gles30 Usable only as internal texture format in OpenGL - * ES 2.0, see @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB10A2". - */ - RGB10A2 = GL_RGB10_A2, - - /** - * RGBA, non-normalized unsigned, each RGB component 10bit, alpha 2bit. - * @requires_gl33 %Extension @extension{ARB,texture_rgb10_a2ui} - * @requires_gles30 Only normalized integral formats are available - * in OpenGL ES 2.0. - */ - RGB10A2UI = GL_RGB10_A2UI, - #endif - - /** RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. */ - RGB5A1 = GL_RGB5_A1, - - /** RGBA, normalized unsigned, each component 4bit. */ - RGBA4 = GL_RGBA4, - - #ifndef MAGNUM_TARGET_GLES - /** - * RGB, float, red and green 11bit, blue 10bit. - * @requires_gl30 %Extension @extension{EXT,packed_float} - * @requires_gl Usable only as internal texture format in OpenGL - * ES, see @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::R11FG11FB10F". - */ - R11FG11FB10F = GL_R11F_G11F_B10F, - #endif - - /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is - GL_ARB_ES2_compatibility */ - #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) - /** RGB, normalized unsigned, red and blue 5bit, green 6bit. */ - RGB565 = GL_RGB565, - #endif - - /** - * sRGBA, each component normalized unsigned byte. - * @requires_gles30 %Extension @es_extension{EXT,sRGB} - */ - #ifndef MAGNUM_TARGET_GLES2 - SRGB8Alpha8 = GL_SRGB8_ALPHA8, - #else - SRGB8Alpha8 = GL_SRGB8_ALPHA8_EXT, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Depth component, size implementation-dependent. - * @todo is this allowed in core? - * @deprecated Prefer to use exactly specified version of this - * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::DepthComponent16". - * @requires_gl Use exactly specified format in OpenGL ES instead. - */ - DepthComponent = GL_DEPTH_COMPONENT, - #endif - - /** Depth component, 16bit. */ - DepthComponent16 = GL_DEPTH_COMPONENT16, - - /** - * Depth component, 24bit. - * @requires_gles30 %Extension @es_extension{OES,depth24} - */ - #ifndef MAGNUM_TARGET_GLES2 - DepthComponent24 = GL_DEPTH_COMPONENT24, - #else - DepthComponent24 = GL_DEPTH_COMPONENT24_OES, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * Depth component, 32bit. - * @requires_es_extension %Extension @es_extension{OES,depth32} - */ - #ifndef MAGNUM_TARGET_GLES - DepthComponent32 = GL_DEPTH_COMPONENT32, - #else - DepthComponent32 = GL_DEPTH_COMPONENT32_OES, - #endif - #endif - - #ifndef MAGNUM_TARGET_GLES2 - /** - * Depth component, 32bit float. - * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 Only integral depth textures are available in - * OpenGL ES 2.0. - */ - DepthComponent32F = GL_DEPTH_COMPONENT32F, - #endif - - #ifndef MAGNUM_TARGET_GLES - /** - * Stencil index, size implementation-dependent. - * @deprecated Prefer to use exactly specified version of this - * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::StencilIndex8". - * @requires_gl Use exactly specified format in OpenGL ES instead. - */ - StencilIndex = GL_STENCIL_INDEX, - #endif - - #ifndef MAGNUM_TARGET_GLES3 - /** - * 1-bit stencil index. - * @requires_es_extension %Extension @es_extension{OES,stencil1} - */ - #ifndef MAGNUM_TARGET_GLES - StencilIndex1 = GL_STENCIL_INDEX1, - #else - StencilIndex1 = GL_STENCIL_INDEX1_OES, - #endif - - /** - * 4-bit stencil index. - * @requires_es_extension %Extension @es_extension{OES,stencil4} - */ - #ifndef MAGNUM_TARGET_GLES - StencilIndex4 = GL_STENCIL_INDEX4, - #else - StencilIndex4 = GL_STENCIL_INDEX4_OES, - #endif - #endif - - /** 8-bit stencil index. */ - StencilIndex8 = GL_STENCIL_INDEX8, - - #ifndef MAGNUM_TARGET_GLES - /** - * 16-bit stencil index. - * @requires_gl At most 8bit stencil index is available in OpenGL - * ES. - */ - StencilIndex16 = GL_STENCIL_INDEX16, - - /** - * Depth and stencil component, size implementation-dependent. - * @deprecated Prefer to use exactly specified version of this - * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::Depth24Stencil8". - * @requires_gl Use exactly specified format in OpenGL ES instead. - */ - DepthStencil = GL_DEPTH_STENCIL, - #endif - - /** - * 24bit depth and 8bit stencil component. - * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} - * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} - */ - #ifdef MAGNUM_TARGET_GLES2 - Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES - #else - Depth24Stencil8 = GL_DEPTH24_STENCIL8, - - /** - * 32bit float depth component and 8bit stencil component. - * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 Only integral depth textures are available in - * OpenGL ES 2.0. - */ - Depth32FStencil8 = GL_DEPTH32F_STENCIL8 - #endif - }; - /** * @brief Constructor * @@ -562,17 +92,17 @@ class MAGNUM_EXPORT Renderbuffer { * @see @fn_gl{BindRenderbuffer}, @fn_gl{RenderbufferStorage} or * @fn_gl_extension{NamedRenderbufferStorage,EXT,direct_state_access} */ - inline void setStorage(InternalFormat internalFormat, const Vector2i& size) { + inline void setStorage(RenderbufferFormat internalFormat, const Vector2i& size) { (this->*storageImplementation)(internalFormat, size); } private: static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); - typedef void(Renderbuffer::*StorageImplementation)(InternalFormat, const Vector2i&); - void MAGNUM_LOCAL storageImplementationDefault(InternalFormat internalFormat, const Vector2i& size); + typedef void(Renderbuffer::*StorageImplementation)(RenderbufferFormat, const Vector2i&); + void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageImplementationDSA(InternalFormat internalFormat, const Vector2i& size); + void MAGNUM_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size); #endif static StorageImplementation storageImplementation; diff --git a/src/RenderbufferFormat.h b/src/RenderbufferFormat.h new file mode 100644 index 000000000..f0d3de92f --- /dev/null +++ b/src/RenderbufferFormat.h @@ -0,0 +1,504 @@ +#ifndef Magnum_RenderbufferFormat_h +#define Magnum_RenderbufferFormat_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Enum Magnum::RenderbufferFormat + */ + +#include "OpenGL.h" + +namespace Magnum { + +/** +@brief Internal renderbuffer format + +@see Renderbuffer +@todo RGB, RGB8 ES only (ES3 + @es_extension{OES,rgb8_rgba8}) + */ +enum class RenderbufferFormat: GLenum { + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::RenderbufferFormat "RenderbufferFormat::R8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + Red = GL_RED, + #endif + + /** + * Red component, normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} + */ + #ifndef MAGNUM_TARGET_GLES2 + R8 = GL_R8, + #else + R8 = GL_R8_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Red and green component, normalized unsigned, size + * implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::RenderbufferFormat "RenderbufferFormat::RG8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + RG = GL_RG, + #endif + + /** + * Red and green component, each normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} + */ + #ifndef MAGNUM_TARGET_GLES2 + RG8 = GL_RG8, + #else + RG8 = GL_RG8_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * RGBA, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::RenderbufferFormat "RenderbufferFormat::RGBA8". + * @requires_gl Use exactly specified format in OpenGL ES 2.0 instead. + */ + RGBA = GL_RGBA, + #endif + + /** + * RGBA, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{ARM,rgba8} or @es_extension{OES,rgb8_rgba8} + */ + #ifndef MAGNUM_TARGET_GLES2 + RGBA8 = GL_RGBA8, + #else + RGBA8 = GL_RGBA8_OES, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + R16 = GL_R16, + + /** + * Red and green component, each normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RG16 = GL_RG16, + + /** + * RGB, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RGB16 = GL_RGB16, + + /** + * RGBA, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RGBA16 = GL_RGBA16, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Red component, non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R8UI = GL_R8UI, + + /** + * Red and green component, each non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG8UI = GL_RG8UI, + + /** + * RGBA, each component non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA8UI = GL_RGBA8UI, + + /** + * Red component, non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R8I = GL_R8I, + + /** + * Red and green component, each non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG8I = GL_RG8I, + + /** + * RGBA, each component non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA8I = GL_RGBA8I, + + /** + * Red component, non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R16UI = GL_R16UI, + + /** + * Red and green component, each non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG16UI = GL_RG16UI, + + /** + * RGBA, each component non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA16UI = GL_RGBA16UI, + + /** + * Red component, non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R16I = GL_R16I, + + /** + * Red and green component, each non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG16I = GL_RG16I, + + /** + * RGBA, each component non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA16I = GL_RGBA16I, + + /** + * Red component, non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R32UI = GL_R32UI, + + /** + * Red and green component, each non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG32UI = GL_RG32UI, + + /** + * RGBA, each component non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA32UI = GL_RGBA32UI, + + /** + * Red component, non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R32I = GL_R32I, + + /** + * Red and green component, each non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG32I = GL_RG32I, + + /** + * RGBA, each component non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA32I = GL_RGBA32I, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are available in + * OpenGL ES. + */ + R16F = GL_R16F, + + /** + * Red and green component, each half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are available in + * OpenGL ES. + */ + RG16F = GL_RG16F, + + /** + * RGBA, each component half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are available in + * OpenGL ES. + */ + RGBA16F = GL_RGBA16F, + + /** + * Red component, float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are available in + * OpenGL ES. + */ + R32F = GL_R32F, + + /** + * Red and green component, each float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are available in + * OpenGL ES. + */ + RG32F = GL_RG32F, + + /** + * RGBA, each component float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are available in + * OpenGL ES. + */ + RGBA32F = GL_RGBA32F, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gles30 Usable only as internal texture format in OpenGL ES + * 2.0, see @ref Magnum::TextureFormat "TextureFormat::RGB10A2". + */ + RGB10A2 = GL_RGB10_A2, + + /** + * RGBA, non-normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gl33 %Extension @extension{ARB,texture_rgb10_a2ui} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB10A2UI = GL_RGB10_A2UI, + #endif + + /** RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. */ + RGB5A1 = GL_RGB5_A1, + + /** RGBA, normalized unsigned, each component 4bit. */ + RGBA4 = GL_RGBA4, + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, float, red and green 11bit, blue 10bit. + * @requires_gl30 %Extension @extension{EXT,packed_float} + * @requires_gl Usable only as internal texture format in OpenGL ES, see + * @ref Magnum::TextureFormat "TextureFormat::R11FG11FB10F". + */ + R11FG11FB10F = GL_R11F_G11F_B10F, + #endif + + /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is + GL_ARB_ES2_compatibility */ + #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) + /** RGB, normalized unsigned, red and blue 5bit, green 6bit. */ + RGB565 = GL_RGB565, + #endif + + /** + * sRGBA, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{EXT,sRGB} + */ + #ifndef MAGNUM_TARGET_GLES2 + SRGB8Alpha8 = GL_SRGB8_ALPHA8, + #else + SRGB8Alpha8 = GL_SRGB8_ALPHA8_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Depth component, size implementation-dependent. + * @todo is this allowed in core? + * @deprecated Prefer to use exactly specified version of this format, e.g. + * @ref Magnum::RenderbufferFormat "RenderbufferFormat::DepthComponent16". + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + DepthComponent = GL_DEPTH_COMPONENT, + #endif + + /** Depth component, 16bit. */ + DepthComponent16 = GL_DEPTH_COMPONENT16, + + /** + * Depth component, 24bit. + * @requires_gles30 %Extension @es_extension{OES,depth24} + */ + #ifndef MAGNUM_TARGET_GLES2 + DepthComponent24 = GL_DEPTH_COMPONENT24, + #else + DepthComponent24 = GL_DEPTH_COMPONENT24_OES, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * Depth component, 32bit. + * @requires_es_extension %Extension @es_extension{OES,depth32} + */ + #ifndef MAGNUM_TARGET_GLES + DepthComponent32 = GL_DEPTH_COMPONENT32, + #else + DepthComponent32 = GL_DEPTH_COMPONENT32_OES, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Depth component, 32bit float. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in OpenGL ES + * 2.0. + */ + DepthComponent32F = GL_DEPTH_COMPONENT32F, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Stencil index, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this format, e.g. + * @ref Magnum::RenderbufferFormat "RenderbufferFormat::StencilIndex8". + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + StencilIndex = GL_STENCIL_INDEX, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * 1-bit stencil index. + * @requires_es_extension %Extension @es_extension{OES,stencil1} + */ + #ifndef MAGNUM_TARGET_GLES + StencilIndex1 = GL_STENCIL_INDEX1, + #else + StencilIndex1 = GL_STENCIL_INDEX1_OES, + #endif + + /** + * 4-bit stencil index. + * @requires_es_extension %Extension @es_extension{OES,stencil4} + */ + #ifndef MAGNUM_TARGET_GLES + StencilIndex4 = GL_STENCIL_INDEX4, + #else + StencilIndex4 = GL_STENCIL_INDEX4_OES, + #endif + #endif + + /** 8-bit stencil index. */ + StencilIndex8 = GL_STENCIL_INDEX8, + + #ifndef MAGNUM_TARGET_GLES + /** + * 16-bit stencil index. + * @requires_gl At most 8bit stencil index is available in OpenGL ES. + */ + StencilIndex16 = GL_STENCIL_INDEX16, + + /** + * Depth and stencil component, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this format, e.g. + * @ref Magnum::RenderbufferFormat "RenderbufferFormat::Depth24Stencil8". + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + DepthStencil = GL_DEPTH_STENCIL, + #endif + + /** + * 24bit depth and 8bit stencil component. + * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} + * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} + */ + #ifdef MAGNUM_TARGET_GLES2 + Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES + #else + Depth24Stencil8 = GL_DEPTH24_STENCIL8, + + /** + * 32bit float depth component and 8bit stencil component. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in OpenGL ES + * 2.0. + */ + Depth32FStencil8 = GL_DEPTH32F_STENCIL8 + #endif +}; + +} + +#endif diff --git a/src/Test/AbstractImageTest.cpp b/src/Test/AbstractImageTest.cpp index 2f1e475ec..2675ad658 100644 --- a/src/Test/AbstractImageTest.cpp +++ b/src/Test/AbstractImageTest.cpp @@ -26,6 +26,7 @@ #include #include "AbstractImage.h" +#include "ImageFormat.h" namespace Magnum { namespace Test { @@ -44,14 +45,14 @@ AbstractImageTest::AbstractImageTest() { void AbstractImageTest::debugFormat() { std::ostringstream o; - Debug(&o) << AbstractImage::Format::RGBA; - CORRADE_COMPARE(o.str(), "AbstractImage::Format::RGBA\n"); + Debug(&o) << ImageFormat::RGBA; + CORRADE_COMPARE(o.str(), "ImageFormat::RGBA\n"); } void AbstractImageTest::debugType() { std::ostringstream o; - Debug(&o) << AbstractImage::Type::UnsignedShort5551; - CORRADE_COMPARE(o.str(), "AbstractImage::Type::UnsignedShort5551\n"); + Debug(&o) << ImageType::UnsignedShort5551; + CORRADE_COMPARE(o.str(), "ImageType::UnsignedShort5551\n"); } }} diff --git a/src/Text/DistanceFieldGlyphCache.cpp b/src/Text/DistanceFieldGlyphCache.cpp index af4a842d7..2f6dd5c1f 100644 --- a/src/Text/DistanceFieldGlyphCache.cpp +++ b/src/Text/DistanceFieldGlyphCache.cpp @@ -26,15 +26,16 @@ #include "Extensions.h" #include "Image.h" +#include "TextureFormat.h" #include "TextureTools/DistanceField.h" namespace Magnum { namespace Text { namespace { #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) - const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::R8; + const TextureFormat internalFormat = TextureFormat::R8; #else - const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::Red; + const TextureFormat internalFormat = TextureFormat::Red; #endif } diff --git a/src/Text/GlyphCache.cpp b/src/Text/GlyphCache.cpp index ad6c81aee..268945b09 100644 --- a/src/Text/GlyphCache.cpp +++ b/src/Text/GlyphCache.cpp @@ -26,15 +26,16 @@ #include "Extensions.h" #include "Image.h" +#include "TextureFormat.h" #include "TextureTools/Atlas.h" namespace Magnum { namespace Text { namespace { #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) - const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::R8; + const TextureFormat internalFormat = TextureFormat::R8; #else - const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::Red; + const TextureFormat internalFormat = TextureFormat::Red; #endif } @@ -48,7 +49,7 @@ GlyphCache::GlyphCache(const Vector2i& size): _size(size) { initialize(internalFormat, size); } -GlyphCache::GlyphCache(const Vector2i& size, const AbstractTexture::InternalFormat internalFormat): _size(size) { +GlyphCache::GlyphCache(const Vector2i& size, const TextureFormat internalFormat): _size(size) { initialize(internalFormat, size); } @@ -57,7 +58,7 @@ GlyphCache::GlyphCache(const Vector2i& size, const Vector2i& padding): _size(siz GlyphCache::~GlyphCache() = default; /** @todo Delegating constructor when support for GCC 4.6 is dropped */ -void GlyphCache::initialize(const AbstractTexture::InternalFormat internalFormat, const Vector2i& size) { +void GlyphCache::initialize(const TextureFormat internalFormat, const Vector2i& size) { #ifndef MAGNUM_TARGET_GLES MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_storage); #else diff --git a/src/Text/GlyphCache.h b/src/Text/GlyphCache.h index 6d452a72c..1b6c5556c 100644 --- a/src/Text/GlyphCache.h +++ b/src/Text/GlyphCache.h @@ -62,7 +62,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache { * @param size Glyph cache texture size * @param internalFormat Internal texture format */ - explicit GlyphCache(const Vector2i& size, Texture2D::InternalFormat internalFormat); + explicit GlyphCache(const Vector2i& size, TextureFormat internalFormat); /** * @brief Constructor @@ -142,7 +142,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache { /* Used from DistanceFieldGlyphCache */ explicit MAGNUM_LOCAL GlyphCache(const Vector2i& size, const Vector2i& padding); - void MAGNUM_LOCAL initialize(Texture2D::InternalFormat internalFormat, const Vector2i& size); + void MAGNUM_LOCAL initialize(TextureFormat internalFormat, const Vector2i& size); const Vector2i _size; Texture2D _texture; diff --git a/src/Texture.h b/src/Texture.h index 49f9be261..8d6ec859a 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -46,14 +46,14 @@ data from e.g. Image. Example configuration of high quality texture with trilinear anisotropic filtering, i.e. the best you can ask for: @code void* data; -Image2D image({4096, 4096}, Image2D::Components::RGBA, Image2D::ComponentType::UnsignedByte, data); +Image2D image({4096, 4096}, ImageFormat::RGBA, ImageType::UnsignedByte, data); Texture2D texture; texture.setMagnificationFilter(Texture2D::Filter::Linear) ->setMinificationFilter(Texture2D::Filter::Linear, Texture2D::Mipmap::Linear) ->setWrapping(Texture2D::Wrapping::ClampToEdge) ->setMaxAnisotropy(Texture2D::maxSupportedAnisotropy) - ->setStorage(Math::log2(4096)+1, Texture2D::Format::RGBA8, {4096, 4096}) + ->setStorage(Math::log2(4096)+1, TextureFormat::RGBA8, {4096, 4096}) ->setSubImage(0, {}, &image) ->generateMipmap(); @endcode @@ -84,11 +84,11 @@ array with 16 layers of 64x64 images: Texture3D texture(Texture3D::Target::Texture2DArray); texture.setMagnificationFilter(Texture2D::Filter::Linear) // ... - ->setStorage(levels, Texture2D::Format::RGBA8, {64, 64,16}); + ->setStorage(levels, TextureFormat::RGBA8, {64, 64,16}); for(std::size_t i = 0; i != 16; ++i) { void* data = ...; - Image2D image({64, 64}, Image3D::Components::RGBA, Image3D::ComponentType::UnsignedByte, image); + Image2D image({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, image); texture->setSubImage(0, Vector3i::zAxis(i), image); } @@ -245,7 +245,7 @@ template class Texture: public AbstractTexture { * @requires_gl42 %Extension @extension{ARB,texture_storage} * @requires_gles30 %Extension @es_extension{EXT,texture_storage} */ - inline Texture* setStorage(Int levels, InternalFormat internalFormat, const typename DimensionTraits::VectorType& size) { + inline Texture* setStorage(Int levels, TextureFormat internalFormat, const typename DimensionTraits::VectorType& size) { DataHelper::setStorage(this, _target, levels, internalFormat, size); return this; } @@ -313,7 +313,7 @@ template class Texture: public AbstractTexture { * @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/ * @fn_gl_extension{TextureImage3D,EXT,direct_state_access} */ - template inline Texture* setImage(Int level, InternalFormat internalFormat, Image* image) { + template inline Texture* setImage(Int level, TextureFormat internalFormat, Image* image) { DataHelper::setImage(this, _target, level, internalFormat, image); return this; } diff --git a/src/TextureFormat.h b/src/TextureFormat.h new file mode 100644 index 000000000..7857540f7 --- /dev/null +++ b/src/TextureFormat.h @@ -0,0 +1,823 @@ +#ifndef Magnum_TextureFormat_h +#define Magnum_TextureFormat_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Enum Magnum::TextureFormat + */ + +#include "OpenGL.h" + +namespace Magnum { + +/** +@brief Internal texture format + +@see Texture, CubeMapTexture, CubeMapTextureArray +*/ +enum class TextureFormat: GLenum { + /** + * Red component, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::TextureFormat "TextureFormat::R8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} + */ + #ifndef MAGNUM_TARGET_GLES2 + Red = GL_RED, + #else + Red = GL_RED_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Red component, normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 Use @ref Magnum::TextureFormat "TextureFormat::Red" in + * OpenGL ES 2.0 instead. + */ + R8 = GL_R8, + #endif + + /** + * Red and green component, normalized unsigned, size + * implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::TextureFormat "TextureFormat::RG8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} + */ + #ifndef MAGNUM_TARGET_GLES2 + RG = GL_RG, + #else + RG = GL_RG_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Red and green component, each normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 Use @ref Magnum::TextureFormat "TextureFormat::RG" in + * OpenGL ES 2.0 instead. + */ + RG8 = GL_RG8, + #endif + + /** + * RGB, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::TextureFormat "TextureFormat::RGB8". + */ + RGB = GL_RGB, + + /** + * RGB, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ + #ifndef MAGNUM_TARGET_GLES2 + RGB8 = GL_RGB8, + #else + RGB8 = GL_RGB8_OES, + #endif + + /** + * RGBA, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this format, + * e.g. @ref Magnum::TextureFormat "TextureFormat::RGBA8". + */ + RGBA = GL_RGBA, + + /** + * RGBA, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ + #ifndef MAGNUM_TARGET_GLES2 + RGBA8 = GL_RGBA8, + #else + RGBA8 = GL_RGBA8_OES, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Red component, normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL ES 2.0. + */ + R8Snorm = GL_R8_SNORM, + + /** + * Red and green component, each normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL ES 2.0. + */ + RG8Snorm = GL_RG8_SNORM, + + /** + * RGB, each component normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL ES 2.0. + */ + RGB8Snorm = GL_RGB8_SNORM, + + /** + * RGBA, each component normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL ES 2.0. + */ + RGBA8Snorm = GL_RGBA8_SNORM, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + R16 = GL_R16, + + /** + * Red and green component, each normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RG16 = GL_RG16, + + /** + * RGB, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RGB16 = GL_RGB16, + + /** + * RGBA, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RGBA16 = GL_RGBA16, + + /** + * Red component, normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + R16Snorm = GL_R16_SNORM, + + /** + * Red and green component, each normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RG16Snorm = GL_RG16_SNORM, + + /** + * RGB, each component normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RGB16Snorm = GL_RGB16_SNORM, + + /** + * RGBA, each component normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gl Only byte-sized normalized formats are available in OpenGL + * ES. + */ + RGBA16Snorm = GL_RGBA16_SNORM, + #endif + + /** + * Red component, non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R8UI = GL_R8UI, + + /** + * Red and green component, each non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG8UI = GL_RG8UI, + + /** + * RGB, each component non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB8UI = GL_RGB8UI, + + /** + * RGBA, each component non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA8UI = GL_RGBA8UI, + + /** + * Red component, non-normalized signed byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R8I = GL_R8I, + + /** + * Red and green component, each non-normalized signed byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG8I = GL_RG8I, + + /** + * RGB, each component non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB8I = GL_RGB8I, + + /** + * RGBA, each component non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA8I = GL_RGBA8I, + + /** + * Red component, non-normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R16UI = GL_R16UI, + + /** + * Red and green component, each non-normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG16UI = GL_RG16UI, + + /** + * RGB, each component non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB16UI = GL_RGB16UI, + + /** + * RGBA, each component non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA16UI = GL_RGBA16UI, + + /** + * Red component, non-normalized signed short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R16I = GL_R16I, + + /** + * Red and green component, each non-normalized signed short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG16I = GL_RG16I, + + /** + * RGB, each component non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB16I = GL_RGB16I, + + /** + * RGBA, each component non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA16I = GL_RGBA16I, + + /** + * Red component, non-normalized unsigned int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R32UI = GL_R32UI, + + /** + * Red and green component, each non-normalized unsigned int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG32UI = GL_RG32UI, + + /** + * RGB, each component non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB32UI = GL_RGB32UI, + + /** + * RGBA, each component non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA32UI = GL_RGBA32UI, + + /** + * Red component, non-normalized signed int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R32I = GL_R32I, + + /** + * Red and green component, each non-normalized signed int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG32I = GL_RG32I, + + /** + * RGB, each component non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB32I = GL_RGB32I, + + /** + * RGBA, each component non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA32I = GL_RGBA32I, + + /** + * Red component, half float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R16F = GL_R16F, + + /** + * Red and green component, each half float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG16F = GL_RG16F, + + /** + * RGB, each component half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB16F = GL_RGB16F, + + /** + * RGBA, each component half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA16F = GL_RGBA16F, + + /** + * Red component, float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R32F = GL_R32F, + + /** + * Red and green component, each float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RG32F = GL_RG32F, + + /** + * RGB, each component float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB32F = GL_RGB32F, + + /** + * RGBA, each component float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGBA32F = GL_RGBA32F, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, normalized unsigned, red and green component 3bit, blue 2bit. + * @requires_gl Packed 8bit types are not available in OpenGL ES. + */ + R3B3G2 = GL_R3_G3_B2, + + /** + * RGB, each component normalized unsigned 4bit. + * @requires_gl Packed 12bit types are not available in OpenGL ES. + */ + RGB4 = GL_RGB4, + + /** + * RGB, each component normalized unsigned 5bit. + * @requires_gl Use @ref Magnum::TextureFormat "TextureFormat::RGB5A1" or + * @ref Magnum::TextureFormat "TextureFormat::RGB565" in OpenGL ES. + */ + RGB5 = GL_RGB5, + #endif + + /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is + GL_ARB_ES2_compatibility */ + #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * RGB, normalized unsigned, red and blue component 5bit, green 6bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ + RGB565 = GL_RGB565, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * RGB, each component normalized unsigned 10bit. + * @requires_es_extension %Extension @es_extension{OES,required_internalformat} + * and @es_extension{EXT,texture_type_2_10_10_10_REV} + */ + #ifndef MAGNUM_TARGET_GLES + RGB10 = GL_RGB10, + #else + RGB10 = GL_RGB10_EXT, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, each component normalized unsigned 12bit. + * @requires_gl Packed 36bit types are not available in OpenGL ES. + */ + RGB12 = GL_RGB12, + + /** + * RGBA, normalized unsigned, each component 2bit. + * @requires_gl Packed 8bit types are not available in OpenGL ES. + */ + RGBA2 = GL_RGBA2, + #endif + + /** + * RGBA, normalized unsigned, each component 4bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ + RGBA4 = GL_RGBA4, + + /** + * RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ + RGB5A1 = GL_RGB5_A1, + + /** + * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + * and @es_extension{EXT,texture_type_2_10_10_10_REV} + */ + #ifndef MAGNUM_TARGET_GLES2 + RGB10A2 = GL_RGB10_A2, + #else + RGB10A2 = GL_RGB10_A2_EXT, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * RGBA, non-normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gl33 %Extension @extension{ARB,texture_rgb10_a2ui} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + RGB10A2UI = GL_RGB10_A2UI, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * RGBA, each component normalized unsigned 12bit. + * @requires_gl Packed 48bit types are not available in OpenGL ES. + */ + RGBA12 = GL_RGBA12, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * RGB, float, red and green component 11bit, blue 10bit. + * @requires_gl30 %Extension @extension{EXT,packed_float} + * @requires_gles30 Only normalized integral formats are available in + * OpenGL ES 2.0. + */ + R11FG11FB10F = GL_R11F_G11F_B10F, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * RGB, unsigned with exponent, each RGB component 9bit, exponent 5bit. + * @requires_gl30 %Extension @extension{EXT,texture_shared_exponent} + * @requires_gles30 Use @ref Magnum::TextureFormat "TextureFormat::RGB" in + * OpenGL ES 2.0 instead. + */ + RGB9E5 = GL_RGB9_E5, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * sRGB, normalized unsigned, size implementation-dependent. + * @todo is this allowed in core? + * @deprecated Prefer to use the exactly specified version of this format, + * i.e. @ref Magnum::TextureFormat "TextureFormat::SRGB8". + * @requires_es_extension %Extension @es_extension{EXT,sRGB} in OpenGL ES + * 2.0, use @ref Magnum::TextureFormat "TextureFormat::SRGB8" in + * OpenGL ES 3.0 instead. + */ + #ifndef MAGNUM_TARGET_GLES + SRGB = GL_SRGB, + #else + SRGB = GL_SRGB_EXT, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * sRGB, each component normalized unsigned byte. + * @requires_gles30 Use @ref Magnum::TextureFormat "TextureFormat::SRGB" in + * OpenGL ES 2.0 instead. + */ + SRGB8 = GL_SRGB8, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * sRGBA, normalized unsigned, size implementation-dependent. + * @todo is this allowed in core? + * @deprecated Prefer to use the exactly specified version of this format, + * i.e. @ref Magnum::TextureFormat "TextureFormat::SRGB8Alpha8". + * @requires_es_extension %Extension @es_extension{EXT,sRGB} in OpenGL ES + * 2.0, use @ref Magnum::TextureFormat "TextureFormat::SRGB8Alpha8" in + * OpenGL ES 3.0 instead. + */ + #ifndef MAGNUM_TARGET_GLES + SRGBAlpha = GL_SRGB_ALPHA, + #else + SRGBAlpha = GL_SRGB_ALPHA_EXT, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * sRGBA, each component normalized unsigned byte. + * @requires_gles30 Use @ref Magnum::TextureFormat "TextureFormat::SRGBAlpha" + * in OpenGL ES 2.0 instead. + */ + SRGB8Alpha8 = GL_SRGB8_ALPHA8, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Compressed red channel, normalized unsigned. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Generic texture compression is not available in OpenGL ES. + */ + CompressedRed = GL_COMPRESSED_RED, + + /** + * Compressed red and green channel, normalized unsigned. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Generic texture compression is not available in OpenGL ES. + */ + CompressedRG = GL_COMPRESSED_RG, + + /** + * Compressed RGB, normalized unsigned. + * @requires_gl Generic texture compression is not available in OpenGL ES. + */ + CompressedRGB = GL_COMPRESSED_RGB, + + /** + * Compressed RGBA, normalized unsigned. + * @requires_gl Generic texture compression is not available in OpenGL ES. + */ + CompressedRGBA = GL_COMPRESSED_RGBA, + + /** + * RTGC compressed red channel, normalized unsigned. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES. + */ + CompressedRedRtgc1 = GL_COMPRESSED_RED_RGTC1, + + /** + * RTGC compressed red and green channel, normalized unsigned. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES. + */ + CompressedRGRgtc2 = GL_COMPRESSED_RG_RGTC2, + + /** + * RTGC compressed red channel, normalized signed. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES. + */ + CompressedSignedRedRgtc1 = GL_COMPRESSED_SIGNED_RED_RGTC1, + + /** + * RTGC compressed red and green channel, normalized signed. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in OpenGL ES. + */ + CompressedSignedRGRgtc2 = GL_COMPRESSED_SIGNED_RG_RGTC2, + + /* These are named with _ARB suffix, because glcorearb.h doesn't + have suffixless version (?!) and GLEW has it without suffix as + late as of 1.8.0 { */ + + /** + * BPTC compressed RGBA, normalized unsigned. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES. + */ + CompressedRGBABtpcUnorm = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, + + /** + * BPTC compressed sRGBA, normalized unsigned. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES. + */ + CompressedSRGBAlphaBtpcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, + + /** + * BPTC compressed RGB, unsigned float. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES. + */ + CompressedRGBBptcUnsignedFloat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, + + /** + * BPTC compressed RGB, signed float. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in OpenGL ES. + */ + CompressedRGBBptcSignedFloat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, + + /*}*/ + #endif + + /** + * Depth component, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this format, e.g. + * @ref Magnum::TextureFormat "TextureFormat::DepthComponent16". + * @requires_gles30 %Extension @es_extension{OES,depth_texture} or + * @es_extension{ANGLE,depth_texture} + */ + DepthComponent = GL_DEPTH_COMPONENT, + + /** + * Depth and stencil component, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this format, e.g. + * @ref Magnum::TextureFormat "TextureFormat::Depth24Stencil8". + * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} + */ + #ifndef MAGNUM_TARGET_GLES2 + DepthStencil = GL_DEPTH_STENCIL, + #else + DepthStencil = GL_DEPTH_STENCIL_OES, + #endif + + /** + * Depth component, 16bit. + * @requires_gles30 %Extension (@es_extension{OES,required_internalformat} + * and @es_extension{OES,depth_texture}) or (@es_extension{EXT,texture_storage} + * and @es_extension{ANGLE,depth_texture}) + */ + DepthComponent16 = GL_DEPTH_COMPONENT16, + + /** + * Depth component, 24bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat}, + * @es_extension{OES,depth_texture} and @es_extension{OES,depth24} + */ + #ifndef MAGNUM_TARGET_GLES2 + DepthComponent24 = GL_DEPTH_COMPONENT24, + #else + DepthComponent24 = GL_DEPTH_COMPONENT24_OES, + #endif + + #ifndef MAGNUM_TARGET_GLES3 + /** + * Depth component, 32bit. + * @requires_es_extension %Extension (@es_extension{OES,required_internalformat}, + * @es_extension{OES,depth_texture} and @es_extension{OES,depth32}) or + * (@es_extension{EXT,texture_storage} and @es_extension{ANGLE,depth_texture}) + */ + #ifndef MAGNUM_TARGET_GLES2 + DepthComponent32 = GL_DEPTH_COMPONENT32, + #else + DepthComponent32 = GL_DEPTH_COMPONENT32_OES, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Depth component, 32bit float. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in OpenGL ES + * 2.0. + */ + DepthComponent32F = GL_DEPTH_COMPONENT32F, + #endif + + /** + * 24bit depth and 8bit stencil component. + * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} + * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} and + * (@es_extension{OES,required_internalformat} or + * (@es_extension{EXT,texture_storage} and @es_extension{ANGLE,depth_texture})) + */ + #ifdef MAGNUM_TARGET_GLES2 + Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES + #else + Depth24Stencil8 = GL_DEPTH24_STENCIL8, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * 32bit float depth component and 8bit stencil component. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in OpenGL ES + * 2.0. + */ + Depth32FStencil8 = GL_DEPTH32F_STENCIL8 + #endif +}; + +} + +#endif diff --git a/src/Trade/ImageData.h b/src/Trade/ImageData.h index dbc6a548b..66e110148 100644 --- a/src/Trade/ImageData.h +++ b/src/Trade/ImageData.h @@ -55,7 +55,7 @@ template class ImageData: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline explicit ImageData(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + inline explicit ImageData(const typename DimensionTraits::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** @brief Destructor */ inline ~ImageData() { delete[] _data; }