Browse Source

Text: unconditionally use TextureFormat::Luminance in GlyphCache on ES2.

Because now with the generic formats all images that are in
PixelFormat::R8Unorm are translated to GL::PixelFormat::Luminance on ES2
and WebGL 1. The DistanceFieldGlyphCache still has the original, but
that one didn't really work there in the first place. That'll get
patched later.
pull/233/head
Vladimír Vondruš 8 years ago
parent
commit
e2512ffee2
  1. 8
      doc/changelog.dox
  2. 7
      src/Magnum/Text/GlyphCache.cpp
  3. 10
      src/Magnum/Text/GlyphCache.h

8
doc/changelog.dox

@ -138,6 +138,14 @@ See also:
now expect that the mesh is indexed (instead of silently not doing
anything)
@subsubsection changelog-latest-changes-text Text library
- The @ref Text::GlyphCache now unconditionally uses
@ref GL::TextureFormat::Luminance on ES2 and WebGL 1, instead of trying
@ref GL::TextureFormat::Red there first. That's done for consistency with
@ref GL::pixelFormat(), which unconditionally returns
@ref GL::PixelFormat::Luminance for @ref PixelFormat::R8Unorm.
@subsubsection changelog-latest-changes-plugins Plugins
- @ref Trade::TgaImporter "TgaImporter" and

7
src/Magnum/Text/GlyphCache.cpp

@ -46,15 +46,8 @@ GlyphCache::GlyphCache(const Vector2i& originalSize, const Vector2i& size, const
MAGNUM_ASSERT_GL_EXTENSION_SUPPORTED(GL::Extensions::ARB::texture_rg);
#endif
/** @todo Is there any better way to select proper sized/unsized format on ES2? */
#ifndef MAGNUM_TARGET_GLES2
const GL::TextureFormat internalFormat = GL::TextureFormat::R8;
#elif !defined(MAGNUM_TARGET_WEBGL)
GL::TextureFormat internalFormat;
if(GL::Context::current().isExtensionSupported<GL::Extensions::EXT::texture_rg>()) {
internalFormat = GL::Context::current().isExtensionSupported<GL::Extensions::EXT::texture_storage>() ?
GL::TextureFormat::R8 : GL::TextureFormat::Red;
} else internalFormat = GL::TextureFormat::Luminance;
#else
const GL::TextureFormat internalFormat = GL::TextureFormat::Luminance;
#endif

10
src/Magnum/Text/GlyphCache.h

@ -81,9 +81,13 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* @brief Constructor
*
* Sets internal texture format to red channel only. On desktop OpenGL
* requires @extension{ARB,texture_rg} (also part of OpenGL ES 3.0), in
* ES2 uses @extension{EXT,texture_rg}, if available, or
* @ref GL::TextureFormat::Luminance as fallback.
* requires @extension{ARB,texture_rg} (also part of OpenGL ES 3.0 and
* WebGL 2), on ES2 unconditionally uses @ref GL::TextureFormat::Luminance.
* This is done for consistency with @ref GL::pixelFormat(), which
* unconditionally returns @ref GL::PixelFormat::Luminance for
* @ref PixelFormat::R8Unorm. See
* @ref GlyphCache(GL::TextureFormat, const Vector2i&, const Vector2i&)
* for an alternative.
*/
explicit GlyphCache(const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding);

Loading…
Cancel
Save