Browse Source

Added ES2-only support for GL_LUMINANCE{,_ALPHA}.

It is deprecated, but many ES2 implementations don't support
EXT_texture_rg, thus this is the only way to have single- and
two-component textures without wasting precious memory. The enum value
isn't exposed on desktop OpenGL and ES3. GL_ALPHA is not supported, as
it doesn't bring any new functionality (it is also single-component
and thus can be interchanged with GL_LUMINANCE).
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
f0db90c8ef
  1. 2
      doc/unsupported.dox
  2. 6
      src/AbstractImage.cpp
  3. 6
      src/ImageFormat.cpp
  4. 24
      src/ImageFormat.h
  5. 25
      src/TextureFormat.h

2
doc/unsupported.dox

@ -29,8 +29,6 @@ add any performance gains, is not supported in %Magnum.
@section unsupported-features Unsupported features
- Luminance texture formats (OpenGL ES) are not supported, as they are
deprecated in OpenGL ES 3.0 and not present in core desktop OpenGL.
- Fixed precision data types (OpenGL ES) are not supported, as they occupy the
same memory as floats and they aren't faster than floats on current hardware
anymore.

6
src/AbstractImage.cpp

@ -99,11 +99,17 @@ std::size_t AbstractImage::pixelSize(ImageFormat format, ImageType type) {
case ImageFormat::Blue:
case ImageFormat::GreenInteger:
case ImageFormat::BlueInteger:
#endif
#ifdef MAGNUM_TARGET_GLES2
case ImageFormat::Luminance:
#endif
return 1*size;
case ImageFormat::RG:
#ifndef MAGNUM_TARGET_GLES2
case ImageFormat::RGInteger:
#endif
#ifdef MAGNUM_TARGET_GLES2
case ImageFormat::LuminanceAlpha:
#endif
return 2*size;
case ImageFormat::RGB:

6
src/ImageFormat.cpp

@ -37,7 +37,13 @@ Debug operator<<(Debug debug, ImageFormat value) {
_c(Green)
_c(Blue)
#endif
#ifdef MAGNUM_TARGET_GLES2
_c(Luminance)
#endif
_c(RG)
#ifdef MAGNUM_TARGET_GLES2
_c(LuminanceAlpha)
#endif
_c(RGB)
_c(RGBA)
#ifndef MAGNUM_TARGET_GLES

24
src/ImageFormat.h

@ -68,8 +68,18 @@ enum class ImageFormat: GLenum {
* available in OpenGL ES.
*/
Blue = GL_BLUE,
#endif
/** @todo GL_ALPHA? */
#if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT)
/**
* Floating-point luminance channel. The value is used for all RGB
* channels.
* @deprecated Included for compatibility reasons only, use
* @ref Magnum::ImageFormat "ImageFormat::Red" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::ImageFormat "ImageFormat::Red" instead.
*/
Luminance = GL_LUMINANCE,
#endif
/**
@ -84,6 +94,18 @@ enum class ImageFormat: GLenum {
RG = GL_RG_EXT,
#endif
#if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT)
/**
* Floating-point luminance and alpha channel. First value is used for all
* RGB channels, second value is used for alpha channel.
* @deprecated Included for compatibility reasons only, use
* @ref Magnum::ImageFormat "ImageFormat::RG" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::ImageFormat "ImageFormat::RG" instead.
*/
LuminanceAlpha = GL_LUMINANCE_ALPHA,
#endif
/**
* Floating-point RGB.
* @requires_gl Can't be used for framebuffer reading in OpenGL ES.

25
src/TextureFormat.h

@ -475,7 +475,32 @@ enum class TextureFormat: GLenum {
* @requires_gl Packed 8bit types are not available in OpenGL ES.
*/
R3B3G2 = GL_R3_G3_B2,
#endif
#if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT)
/**
* Luminance, normalized unsigned, single value used for all RGB channels.
* Size implementation-dependent.
* @deprecated Included for compatibility reasons only, use
* @ref Magnum::TextureFormat "TextureFormat::R8" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::TextureFormat "TextureFormat::R8" instead.
*/
Luminance = GL_LUMINANCE,
/**
* Floating-point luminance and alpha channel. First value is used for all
* RGB channels, second value is used for alpha channel. Size
* implementation-dependent.
* @deprecated Included for compatibility reasons only, use
* @ref Magnum::TextureFormat "TextureFormat::RG" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::TextureFormat "TextureFormat::RG" instead.
*/
LuminanceAlpha = GL_LUMINANCE_ALPHA,
#endif
#ifndef MAGNUM_TARGET_GLES
/**
* RGB, each component normalized unsigned 4bit.
* @requires_gl Packed 12bit types are not available in OpenGL ES.

Loading…
Cancel
Save