Browse Source

TgaImporter: return Luminance if EXT_texture_rg is not supported in ES.

Also documented the behavior.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
0eb828f67e
  1. 7
      src/Plugins/TgaImporter/TgaImporter.cpp
  2. 10
      src/Plugins/TgaImporter/TgaImporter.h

7
src/Plugins/TgaImporter/TgaImporter.cpp

@ -33,6 +33,8 @@
#ifdef MAGNUM_TARGET_GLES
#include <algorithm>
#include <Context.h>
#include <Extensions.h>
#include <Swizzle.h>
#endif
@ -117,7 +119,12 @@ ImageData2D* TgaImporter::doImage2D(UnsignedInt) {
/* Grayscale */
} else if(header.imageType == 3) {
#ifdef MAGNUM_TARGET_GLES
format = Context::current() && Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>() ?
ImageFormat::Red : ImageFormat::Luminance;
#else
format = ImageFormat::Red;
#endif
if(header.bpp != 8) {
Error() << "Trade::TgaImporter::TgaImporter::image2D(): unsupported grayscale bits-per-pixel:" << header.bpp;
return nullptr;

10
src/Plugins/TgaImporter/TgaImporter.h

@ -46,6 +46,16 @@ namespace Magnum { namespace Trade {
@brief TGA image importer
Supports uncompressed BGR, BGRA or grayscale images with 8 bits per channel.
The images are imported with @ref ImageType "ImageType::UnsignedByte" and
@ref ImageFormat "ImageFormat::BGR", @ref ImageFormat "ImageFormat::BGRA" or
@ref ImageFormat "ImageFormat::Red" respectively. Grayscale images require
extension @extension{ARB,texture_rg}.
In OpenGL ES BGR and BGRA images are converted to @ref ImageFormat "ImageFormat::RGB"
and @ref ImageFormat "ImageFormat::RGBA". In OpenGL ES 2.0, if @es_extension{EXT,texture_rg}
is not supported, grayscale images use @ref ImageFormat "ImageFormat::Luminance"
instead of @ref ImageFormat "ImageFormat::Red".
*/
class MAGNUM_TRADE_TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
public:

Loading…
Cancel
Save