Browse Source

Moved texture and image formats out of the classes.

Advantages:

 * The enums were large (600-800 lines) and they polluted the header,
   now they are in separate files (except for BufferTexture, which has
   the enum small enough to be left in the same file).
 * Image classes now don't need to include OpenGL headers, as they were
   needed only for the enum values. With advantage of C++11's forward
   enum declarations there is no need to include the enum headers
   anywhere in implementation, only when particular values are needed.
 * The values are now less verbose:

    AbstractTexture::InternalFormat::RGB8 // before
    TextureFormat::RGB8                   // now

 * Resolved another "trivial choice" problem (thanks @JanDupal for
   introducing this term to me): how to specify the format if there are
   ten ways to do it (some being massively confusing):

    Image2D::Format f = AbstractImage::Format::RGB; // too long...
    Image2D::Format f = Image3D::Format::RGBA; // why 3D? this works?
    Image2D::Format f = BufferImage1D::Format::RGBA; // wat?

   It is even worse (and more verbose) with textures:

    Texture2D::InternalFormat f =
        CubeMapTextureArray::InternalFormat::RGB8; // this is allowed?

To have consistent naming this change was done also with
BufferTexture::InternalFormat (now BufferTextureFormat), although there
were no trivial choice issues and the enum isn't too large. But at least
it is now less typing.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
7de45c98b1
  1. 12
      doc/method-chaining.dox
  2. 4
      src/AbstractFramebuffer.cpp
  3. 7
      src/AbstractFramebuffer.h
  4. 187
      src/AbstractImage.cpp
  5. 455
      src/AbstractImage.h
  6. 42
      src/AbstractTexture.cpp
  7. 909
      src/AbstractTexture.h
  8. 2
      src/BufferImage.cpp
  9. 4
      src/BufferImage.h
  10. 9
      src/BufferTexture.cpp
  11. 250
      src/BufferTexture.h
  12. 4
      src/CMakeLists.txt
  13. 8
      src/CubeMapTexture.h
  14. 10
      src/CubeMapTextureArray.h
  15. 2
      src/Image.cpp
  16. 6
      src/Image.h
  17. 128
      src/ImageFormat.cpp
  18. 454
      src/ImageFormat.h
  19. 6
      src/ImageWrapper.h
  20. 11
      src/Magnum.h
  21. 4
      src/Renderbuffer.cpp
  22. 478
      src/Renderbuffer.h
  23. 504
      src/RenderbufferFormat.h
  24. 9
      src/Test/AbstractImageTest.cpp
  25. 5
      src/Text/DistanceFieldGlyphCache.cpp
  26. 9
      src/Text/GlyphCache.cpp
  27. 4
      src/Text/GlyphCache.h
  28. 12
      src/Texture.h
  29. 823
      src/TextureFormat.h
  30. 2
      src/Trade/ImageData.h

12
doc/method-chaining.dox

@ -43,9 +43,9 @@ number of needed bindings. Consider the following example:
@code @code
Texture2D *carDiffuseTexture, *carSpecularTexture, *carBumpTexture; Texture2D *carDiffuseTexture, *carSpecularTexture, *carBumpTexture;
carDiffuseTexture->setStorage(5, Texture2D::InternalFormat::SRGB8); carDiffuseTexture->setStorage(5, TextureFormat::SRGB8);
carSpecularTexture->setStorage(3, Texture2D::InternalFormat::R8); carSpecularTexture->setStorage(3, TextureFormat::R8);
carBumpTexture->setStorage(5, Texture2D::InternalFormat::RGB8); carBumpTexture->setStorage(5, TextureFormat::RGB8);
carDiffuseTexture->setSubImage(0, {}, diffuse); carDiffuseTexture->setSubImage(0, {}, diffuse);
carSpecularTexture->setSubImage(0, {}, specular; carSpecularTexture->setSubImage(0, {}, specular;
carBumpTexture->setSubImage(0, {}, bump); 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 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. configured in one run, reducing count of bind calls from 9 to 3.
@code @code
carDiffuseTexture->setStorage(5, Texture2D::InternalFormat::SRGB8) carDiffuseTexture->setStorage(5, TextureFormat::SRGB8)
->setSubImage(0, {}, diffuse) ->setSubImage(0, {}, diffuse)
->generateMipmap(); ->generateMipmap();
carSpecularTexture->setStorage(3, Texture2D::InternalFormat::R8) carSpecularTexture->setStorage(3, TextureFormat::R8)
->setSubImage(0, {}, diffuse) ->setSubImage(0, {}, diffuse)
->generateMipmap(); ->generateMipmap();
carBumpTexture->setStorage(5, Texture2D::InternalFormat::RGB8) carBumpTexture->setStorage(5, TextureFormat::RGB8)
->setSubImage(0, {}, bump) ->setSubImage(0, {}, bump)
->generateMipmap(); ->generateMipmap();
@endcode @endcode

4
src/AbstractFramebuffer.cpp

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

7
src/AbstractFramebuffer.h

@ -31,7 +31,6 @@
#include <Containers/EnumSet.h> #include <Containers/EnumSet.h>
#include "Math/Geometry/Rectangle.h" #include "Math/Geometry/Rectangle.h"
#include "AbstractImage.h"
#include "Buffer.h" #include "Buffer.h"
namespace Magnum { namespace Magnum {
@ -308,10 +307,10 @@ class MAGNUM_EXPORT AbstractFramebuffer {
void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer); void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer);
#endif #endif
typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, AbstractImage::Format, AbstractImage::Type, std::size_t, GLvoid*); typedef void(*ReadImplementation)(const Vector2i&, const Vector2i&, ImageFormat, ImageType, 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); 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 #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 #endif
static ReadImplementation MAGNUM_LOCAL readImplementation; static ReadImplementation MAGNUM_LOCAL readImplementation;
}; };

187
src/AbstractImage.cpp

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

455
src/AbstractImage.h

@ -31,7 +31,6 @@
#include <cstddef> #include <cstddef>
#include "Magnum.h" #include "Magnum.h"
#include "OpenGL.h"
#include "magnumVisibility.h" #include "magnumVisibility.h"
namespace Magnum { namespace Magnum {
@ -53,442 +52,6 @@ class MAGNUM_EXPORT AbstractImage {
AbstractImage& operator=(AbstractImage&&) = delete; AbstractImage& operator=(AbstractImage&&) = delete;
public: 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) * @brief Pixel size (in bytes)
* @param format Format of the pixel * @param format Format of the pixel
@ -496,23 +59,23 @@ class MAGNUM_EXPORT AbstractImage {
* *
* @see pixelSize() const * @see pixelSize() const
*/ */
static std::size_t pixelSize(Format format, Type type); static std::size_t pixelSize(ImageFormat format, ImageType type);
/** /**
* @brief Constructor * @brief Constructor
* @param format Format of pixel data * @param format Format of pixel data
* @param type Data type of pixel data * @param type Data type of pixel data
*/ */
inline explicit AbstractImage(Format format, Type type): _format(format), _type(type) {} inline explicit AbstractImage(ImageFormat format, ImageType type): _format(format), _type(type) {}
/** @brief Destructor */ /** @brief Destructor */
virtual ~AbstractImage() = 0; virtual ~AbstractImage() = 0;
/** @brief Format of pixel data */ /** @brief Format of pixel data */
inline Format format() const { return _format; } inline ImageFormat format() const { return _format; }
/** @brief Data type of pixel data */ /** @brief Data type of pixel data */
inline Type type() const { return _type; } inline ImageType type() const { return _type; }
/** /**
* @brief Pixel size (in bytes) * @brief Pixel size (in bytes)
@ -528,18 +91,12 @@ class MAGNUM_EXPORT AbstractImage {
#else #else
protected: protected:
#endif #endif
Format _format; ImageFormat _format;
Type _type; ImageType _type;
}; };
inline AbstractImage::~AbstractImage() {} 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 #endif

42
src/AbstractTexture.cpp

@ -306,7 +306,7 @@ void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint le
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */ /** @todo Re-enable when extension wrangler is available for ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -320,12 +320,12 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
#endif #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]); glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]);
} }
#endif #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(); bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */ /** @todo Re-enable when extension wrangler is available for ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -340,12 +340,12 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
} }
#ifndef MAGNUM_TARGET_GLES #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()); glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y());
} }
#endif #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(); bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */ /** @todo Re-enable when extension wrangler is available for ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -360,22 +360,22 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
} }
#ifndef MAGNUM_TARGET_GLES #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()); glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); bindInternal();
glGetTexImage(target, level, GLenum(format), GLenum(type), data); glGetTexImage(target, level, GLenum(format), GLenum(type), data);
} }
void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const 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); 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 #ifndef MAGNUM_TARGET_GLES
bindInternal(); bindInternal();
glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data); glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data);
@ -392,28 +392,28 @@ void AbstractTexture::getImageImplementationRobustness(const GLenum target, cons
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, 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(); bindInternal();
glTexImage1D(target, level, static_cast<GLint>(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexImage1D(target, level, static_cast<GLint>(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, 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<GLenum>(format), static_cast<GLenum>(type), data); glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, 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(); bindInternal();
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, 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<GLenum>(format), static_cast<GLenum>(type), data); glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, 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(); bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -430,34 +430,34 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Int
} }
#ifndef MAGNUM_TARGET_GLES #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<GLenum>(format), static_cast<GLenum>(type), data); glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, 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(); bindInternal();
glTexSubImage1D(target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexSubImage1D(target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, 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<GLenum>(format), static_cast<GLenum>(type), data); glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, 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(); bindInternal();
glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data); glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, 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<GLenum>(format), static_cast<GLenum>(type), data); glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, 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(); bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -474,7 +474,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, 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<GLenum>(format), static_cast<GLenum>(type), data); glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
} }
#endif #endif

909
src/AbstractTexture.h

File diff suppressed because it is too large Load Diff

2
src/BufferImage.cpp

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

4
src/BufferImage.h

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

9
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(); bindInternal();
glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); 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()); 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(); bindInternal();
glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); 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); glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size);
} }
} }
#endif #endif

250
src/BufferTexture.h

@ -26,7 +26,7 @@
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** @file /** @file
* @brief Class Magnum::BufferTexture * @brief Class Magnum::BufferTexture, enum Magnum::BufferTextureFormat
*/ */
#endif #endif
@ -56,7 +56,7 @@ Example usage:
@code @code
Buffer* buffer; Buffer* buffer;
BufferTexture texture; BufferTexture texture;
texture.setBuffer(buffer); texture.setBuffer(BufferTextureFormat::RGB32F, buffer);
constexpr static Vector3 data[] = { constexpr static Vector3 data[] = {
// ... // ...
@ -88,121 +88,6 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture {
BufferTexture& operator=(BufferTexture&&) = delete; BufferTexture& operator=(BufferTexture&&) = delete;
public: 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) {} inline explicit BufferTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {}
/** @copydoc AbstractTexture::bind() */ /** @copydoc AbstractTexture::bind() */
@ -219,7 +104,7 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture {
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer}
* or @fn_gl_extension{TextureBuffer,EXT,direct_state_access} * 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); (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} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer}
* or @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} * 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); (this->*setBufferRangeImplementation)(internalFormat, buffer, offset, size);
} }
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context);
typedef void(BufferTexture::*SetBufferImplementation)(InternalFormat, Buffer*); typedef void(BufferTexture::*SetBufferImplementation)(BufferTextureFormat, Buffer*);
void MAGNUM_LOCAL setBufferImplementationDefault(InternalFormat internalFormat, Buffer* buffer); void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer);
void MAGNUM_LOCAL setBufferImplementationDSA(InternalFormat internalFormat, Buffer* buffer); void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer);
static SetBufferImplementation setBufferImplementation; static SetBufferImplementation setBufferImplementation;
typedef void(BufferTexture::*SetBufferRangeImplementation)(InternalFormat, Buffer*, GLintptr, GLsizeiptr); typedef void(BufferTexture::*SetBufferRangeImplementation)(BufferTextureFormat, Buffer*, GLintptr, GLsizeiptr);
void MAGNUM_LOCAL setBufferRangeImplementationDefault(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size);
void MAGNUM_LOCAL setBufferRangeImplementationDSA(InternalFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size); void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size);
static SetBufferRangeImplementation setBufferRangeImplementation; 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 #endif

4
src/CMakeLists.txt

@ -56,6 +56,7 @@ set(Magnum_SRCS
DefaultFramebuffer.cpp DefaultFramebuffer.cpp
Framebuffer.cpp Framebuffer.cpp
Image.cpp Image.cpp
ImageFormat.cpp
Mesh.cpp Mesh.cpp
OpenGL.cpp OpenGL.cpp
Query.cpp Query.cpp
@ -110,18 +111,21 @@ set(Magnum_HEADERS
Extensions.h Extensions.h
Framebuffer.h Framebuffer.h
Image.h Image.h
ImageFormat.h
ImageWrapper.h ImageWrapper.h
Magnum.h Magnum.h
Mesh.h Mesh.h
OpenGL.h OpenGL.h
Query.h Query.h
Renderbuffer.h Renderbuffer.h
RenderbufferFormat.h
Renderer.h Renderer.h
Resource.h Resource.h
ResourceManager.h ResourceManager.h
Shader.h Shader.h
Swizzle.h Swizzle.h
Texture.h Texture.h
TextureFormat.h
Timeline.h Timeline.h
Types.h Types.h

8
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 Common usage is to fully configure all texture parameters and then set the
data from e.g. set of Image objects: data from e.g. set of Image objects:
@code @code
Image2D positiveX({256, 256}, Image2D::Components::RGBA, Image2D::ComponentType::UnsignedByte, dataPositiveX); Image2D positiveX({256, 256}, ImageFormat::RGBA, ImageType::UnsignedByte, dataPositiveX);
// ... // ...
CubeMapTexture texture; CubeMapTexture texture;
texture.setMagnificationFilter(Texture2D::Filter::Linear) 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::PositiveX, 0, {}, &positiveX)
->setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, &negativeX) ->setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, &negativeX)
// ... // ...
@ -124,7 +124,7 @@ class CubeMapTexture: public AbstractTexture {
* *
* See Texture::setStorage() for more information. * 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); DataHelper<2>::setStorage(this, _target, levels, internalFormat, size);
return this; return this;
} }
@ -170,7 +170,7 @@ class CubeMapTexture: public AbstractTexture {
* *
* See Texture::setImage() for more information. * See Texture::setImage() for more information.
*/ */
template<class Image> inline CubeMapTexture* setImage(Coordinate coordinate, Int level, InternalFormat internalFormat, Image* image) { template<class Image> inline CubeMapTexture* setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, Image* image) {
DataHelper<2>::setImage(this, static_cast<GLenum>(coordinate), level, internalFormat, image); DataHelper<2>::setImage(this, static_cast<GLenum>(coordinate), level, internalFormat, image);
return this; return this;
} }

10
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 Example: array with 16 layers of cube map faces, each face consisting of six
64x64 images: 64x64 images:
@code @code
Image3D dummy({64, 64, 16*6}, Image3D::Components::RGBA, Image3D::ComponentType::UnsignedByte, nullptr); Image3D dummy({64, 64, 16*6}, ImageFormat::RGBA, ImageType::UnsignedByte, nullptr);
CubeMapTextureArray texture; CubeMapTextureArray texture;
texture.setMagnificationFilter(CubeMapTextureArray::Filter::Linear) 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) { for(std::size_t i = 0; i != 16; ++i) {
void* dataPositiveX = ...; 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::PositiveX, 0, {}, imagePositiveX);
texture->setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); texture->setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX);
@ -124,7 +124,7 @@ class CubeMapTextureArray: public AbstractTexture {
* *
* See Texture::setStorage() for more information. * 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); DataHelper<3>::setStorage(this, _target, levels, internalFormat, size);
return this; return this;
} }
@ -173,7 +173,7 @@ class CubeMapTextureArray: public AbstractTexture {
* *
* See Texture::setImage() for more information. * See Texture::setImage() for more information.
*/ */
template<class T> inline CubeMapTextureArray* setImage(Int level, InternalFormat internalFormat, T* image) { template<class T> inline CubeMapTextureArray* setImage(Int level, TextureFormat internalFormat, T* image) {
DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image); DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image);
return this; return this;
} }

2
src/Image.cpp

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

6
src/Image.h

@ -55,7 +55,7 @@ template<UnsignedInt dimensions> class Image: public AbstractImage {
* Note that the image data are not copied on construction, but they * Note that the image data are not copied on construction, but they
* are deleted on class destruction. * are deleted on class destruction.
*/ */
inline explicit Image(const typename DimensionTraits<Dimensions, Int>::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {} inline explicit Image(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {}
/** /**
* @brief Constructor * @brief Constructor
@ -65,7 +65,7 @@ template<UnsignedInt dimensions> class Image: public AbstractImage {
* Dimensions and data pointer are set to zero, call setData() to fill * Dimensions and data pointer are set to zero, call setData() to fill
* the image with data. * the image with data.
*/ */
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 */ /** @brief Destructor */
inline ~Image() { delete[] _data; } inline ~Image() { delete[] _data; }
@ -87,7 +87,7 @@ template<UnsignedInt dimensions> class Image: public AbstractImage {
* Deletes previous data and replaces them with new. Note that the * Deletes previous data and replaces them with new. Note that the
* data are not copied, but they are deleted on destruction. * data are not copied, but they are deleted on destruction.
*/ */
void setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, Format format, Type type, GLvoid* data); void setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type, void* data);
private: private:
Math::Vector<Dimensions, Int> _size; Math::Vector<Dimensions, Int> _size;

128
src/ImageFormat.cpp

@ -0,0 +1,128 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "ImageFormat.h"
#include <Utility/Debug.h>
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
}

454
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š <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Enum Magnum::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

6
src/ImageWrapper.h

@ -62,7 +62,7 @@ template<UnsignedInt dimensions> class ImageWrapper: public AbstractImage {
* Note that the image data are not copied on construction, but they * Note that the image data are not copied on construction, but they
* are deleted on class destruction. * are deleted on class destruction.
*/ */
inline explicit ImageWrapper(const typename DimensionTraits<Dimensions, Int>::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {} inline explicit ImageWrapper(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {}
/** /**
* @brief Constructor * @brief Constructor
@ -73,7 +73,7 @@ template<UnsignedInt dimensions> class ImageWrapper: public AbstractImage {
* Data pointer is set to zero, call setData() to fill the image with * Data pointer is set to zero, call setData() to fill the image with
* data. * data.
*/ */
inline explicit ImageWrapper(const typename DimensionTraits<Dimensions, Int>::VectorType& size, Format format, Type type): AbstractImage(format, type), _size(size), _data(nullptr) {} inline explicit ImageWrapper(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type): AbstractImage(format, type), _size(size), _data(nullptr) {}
/** @brief %Image size */ /** @brief %Image size */
inline typename DimensionTraits<Dimensions, Int>::VectorType size() const { return _size; } inline typename DimensionTraits<Dimensions, Int>::VectorType size() const { return _size; }
@ -90,7 +90,7 @@ template<UnsignedInt dimensions> class ImageWrapper: public AbstractImage {
* passed in constructor. The data are not copied nor deleted on * passed in constructor. The data are not copied nor deleted on
* destruction. * destruction.
*/ */
inline void setData(GLvoid* data) { inline void setData(void* data) {
_data = reinterpret_cast<unsigned char*>(data); _data = reinterpret_cast<unsigned char*>(data);
} }

11
src/Magnum.h

@ -34,6 +34,10 @@
#include "Types.h" #include "Types.h"
#include "magnumConfigure.h" #include "magnumConfigure.h"
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef unsigned int GLenum; /* Needed for *Format and *Type enums */
#endif
namespace Corrade { namespace Corrade {
namespace Utility { namespace Utility {
class Debug; class Debug;
@ -346,6 +350,7 @@ typedef BufferImage<3> BufferImage3D;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
class BufferTexture; class BufferTexture;
enum class BufferTextureFormat: GLenum;
#endif #endif
template<class T = Float> class Color3; template<class T = Float> class Color3;
@ -371,6 +376,9 @@ typedef Image<1> Image1D;
typedef Image<2> Image2D; typedef Image<2> Image2D;
typedef Image<3> Image3D; typedef Image<3> Image3D;
enum class ImageFormat: GLenum;
enum class ImageType: GLenum;
template<UnsignedInt> class ImageWrapper; template<UnsignedInt> class ImageWrapper;
typedef ImageWrapper<1> ImageWrapper1D; typedef ImageWrapper<1> ImageWrapper1D;
typedef ImageWrapper<2> ImageWrapper2D; typedef ImageWrapper<2> ImageWrapper2D;
@ -384,6 +392,7 @@ class SampleQuery;
class TimeQuery; class TimeQuery;
class Renderbuffer; class Renderbuffer;
enum class RenderbufferFormat: GLenum;
enum class ResourceState: UnsignedByte; enum class ResourceState: UnsignedByte;
enum class ResourceDataState: UnsignedByte; enum class ResourceDataState: UnsignedByte;
@ -401,6 +410,8 @@ typedef Texture<1> Texture1D;
typedef Texture<2> Texture2D; typedef Texture<2> Texture2D;
typedef Texture<3> Texture3D; typedef Texture<3> Texture3D;
enum class TextureFormat: GLenum;
class Timeline; class Timeline;
#endif #endif

4
src/Renderbuffer.cpp

@ -63,13 +63,13 @@ void Renderbuffer::initializeContextBasedFunctionality(Context* context) {
#endif #endif
} }
void Renderbuffer::storageImplementationDefault(Renderbuffer::InternalFormat internalFormat, const Vector2i& size) { void Renderbuffer::storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size) {
bind(); bind();
glRenderbufferStorage(GL_RENDERBUFFER, GLenum(internalFormat), size.x(), size.y()); glRenderbufferStorage(GL_RENDERBUFFER, GLenum(internalFormat), size.x(), size.y());
} }
#ifndef MAGNUM_TARGET_GLES #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()); glNamedRenderbufferStorageEXT(_id, GLenum(internalFormat), size.x(), size.y());
} }
#endif #endif

478
src/Renderbuffer.h

@ -60,476 +60,6 @@ class MAGNUM_EXPORT Renderbuffer {
Renderbuffer& operator=(Renderbuffer&&) = delete; Renderbuffer& operator=(Renderbuffer&&) = delete;
public: 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 * @brief Constructor
* *
@ -562,17 +92,17 @@ class MAGNUM_EXPORT Renderbuffer {
* @see @fn_gl{BindRenderbuffer}, @fn_gl{RenderbufferStorage} or * @see @fn_gl{BindRenderbuffer}, @fn_gl{RenderbufferStorage} or
* @fn_gl_extension{NamedRenderbufferStorage,EXT,direct_state_access} * @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); (this->*storageImplementation)(internalFormat, size);
} }
private: private:
static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context); static void MAGNUM_LOCAL initializeContextBasedFunctionality(Context* context);
typedef void(Renderbuffer::*StorageImplementation)(InternalFormat, const Vector2i&); typedef void(Renderbuffer::*StorageImplementation)(RenderbufferFormat, const Vector2i&);
void MAGNUM_LOCAL storageImplementationDefault(InternalFormat internalFormat, const Vector2i& size); void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageImplementationDSA(InternalFormat internalFormat, const Vector2i& size); void MAGNUM_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size);
#endif #endif
static StorageImplementation storageImplementation; static StorageImplementation storageImplementation;

504
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š <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Enum Magnum::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

9
src/Test/AbstractImageTest.cpp

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

5
src/Text/DistanceFieldGlyphCache.cpp

@ -26,15 +26,16 @@
#include "Extensions.h" #include "Extensions.h"
#include "Image.h" #include "Image.h"
#include "TextureFormat.h"
#include "TextureTools/DistanceField.h" #include "TextureTools/DistanceField.h"
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
namespace { namespace {
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::R8; const TextureFormat internalFormat = TextureFormat::R8;
#else #else
const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::Red; const TextureFormat internalFormat = TextureFormat::Red;
#endif #endif
} }

9
src/Text/GlyphCache.cpp

@ -26,15 +26,16 @@
#include "Extensions.h" #include "Extensions.h"
#include "Image.h" #include "Image.h"
#include "TextureFormat.h"
#include "TextureTools/Atlas.h" #include "TextureTools/Atlas.h"
namespace Magnum { namespace Text { namespace Magnum { namespace Text {
namespace { namespace {
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3)
const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::R8; const TextureFormat internalFormat = TextureFormat::R8;
#else #else
const AbstractTexture::InternalFormat internalFormat = AbstractTexture::InternalFormat::Red; const TextureFormat internalFormat = TextureFormat::Red;
#endif #endif
} }
@ -48,7 +49,7 @@ GlyphCache::GlyphCache(const Vector2i& size): _size(size) {
initialize(internalFormat, 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); initialize(internalFormat, size);
} }
@ -57,7 +58,7 @@ GlyphCache::GlyphCache(const Vector2i& size, const Vector2i& padding): _size(siz
GlyphCache::~GlyphCache() = default; GlyphCache::~GlyphCache() = default;
/** @todo Delegating constructor when support for GCC 4.6 is dropped */ /** @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 #ifndef MAGNUM_TARGET_GLES
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_storage); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_storage);
#else #else

4
src/Text/GlyphCache.h

@ -62,7 +62,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* @param size Glyph cache texture size * @param size Glyph cache texture size
* @param internalFormat Internal texture format * @param internalFormat Internal texture format
*/ */
explicit GlyphCache(const Vector2i& size, Texture2D::InternalFormat internalFormat); explicit GlyphCache(const Vector2i& size, TextureFormat internalFormat);
/** /**
* @brief Constructor * @brief Constructor
@ -142,7 +142,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
/* Used from DistanceFieldGlyphCache */ /* Used from DistanceFieldGlyphCache */
explicit MAGNUM_LOCAL GlyphCache(const Vector2i& size, const Vector2i& padding); 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; const Vector2i _size;
Texture2D _texture; Texture2D _texture;

12
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: trilinear anisotropic filtering, i.e. the best you can ask for:
@code @code
void* data; void* data;
Image2D image({4096, 4096}, Image2D::Components::RGBA, Image2D::ComponentType::UnsignedByte, data); Image2D image({4096, 4096}, ImageFormat::RGBA, ImageType::UnsignedByte, data);
Texture2D texture; Texture2D texture;
texture.setMagnificationFilter(Texture2D::Filter::Linear) texture.setMagnificationFilter(Texture2D::Filter::Linear)
->setMinificationFilter(Texture2D::Filter::Linear, Texture2D::Mipmap::Linear) ->setMinificationFilter(Texture2D::Filter::Linear, Texture2D::Mipmap::Linear)
->setWrapping(Texture2D::Wrapping::ClampToEdge) ->setWrapping(Texture2D::Wrapping::ClampToEdge)
->setMaxAnisotropy(Texture2D::maxSupportedAnisotropy) ->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) ->setSubImage(0, {}, &image)
->generateMipmap(); ->generateMipmap();
@endcode @endcode
@ -84,11 +84,11 @@ array with 16 layers of 64x64 images:
Texture3D texture(Texture3D::Target::Texture2DArray); Texture3D texture(Texture3D::Target::Texture2DArray);
texture.setMagnificationFilter(Texture2D::Filter::Linear) 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) { for(std::size_t i = 0; i != 16; ++i) {
void* data = ...; 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); texture->setSubImage(0, Vector3i::zAxis(i), image);
} }
@ -245,7 +245,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @requires_gl42 %Extension @extension{ARB,texture_storage} * @requires_gl42 %Extension @extension{ARB,texture_storage}
* @requires_gles30 %Extension @es_extension{EXT,texture_storage} * @requires_gles30 %Extension @es_extension{EXT,texture_storage}
*/ */
inline Texture<Dimensions>* setStorage(Int levels, InternalFormat internalFormat, const typename DimensionTraits<Dimensions, Int>::VectorType& size) { inline Texture<Dimensions>* setStorage(Int levels, TextureFormat internalFormat, const typename DimensionTraits<Dimensions, Int>::VectorType& size) {
DataHelper<Dimensions>::setStorage(this, _target, levels, internalFormat, size); DataHelper<Dimensions>::setStorage(this, _target, levels, internalFormat, size);
return this; return this;
} }
@ -313,7 +313,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/ * @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/
* @fn_gl_extension{TextureImage3D,EXT,direct_state_access} * @fn_gl_extension{TextureImage3D,EXT,direct_state_access}
*/ */
template<class Image> inline Texture<Dimensions>* setImage(Int level, InternalFormat internalFormat, Image* image) { template<class Image> inline Texture<Dimensions>* setImage(Int level, TextureFormat internalFormat, Image* image) {
DataHelper<Dimensions>::setImage(this, _target, level, internalFormat, image); DataHelper<Dimensions>::setImage(this, _target, level, internalFormat, image);
return this; return this;
} }

823
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š <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Enum Magnum::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

2
src/Trade/ImageData.h

@ -55,7 +55,7 @@ template<UnsignedInt dimensions> class ImageData: public AbstractImage {
* Note that the image data are not copied on construction, but they * Note that the image data are not copied on construction, but they
* are deleted on class destruction. * are deleted on class destruction.
*/ */
inline explicit ImageData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {} inline explicit ImageData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ImageFormat format, ImageType type, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast<unsigned char*>(data)) {}
/** @brief Destructor */ /** @brief Destructor */
inline ~ImageData() { delete[] _data; } inline ~ImageData() { delete[] _data; }

Loading…
Cancel
Save