diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index 93fc2f4aa..ca2e88f42 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -92,6 +92,11 @@ class FramebufferGLTest: public AbstractOpenGLTester { void readBuffer(); #endif void blit(); + + #ifdef MAGNUM_TARGET_GLES2 + private: + TextureFormat rgbaFormatES2, depthStencilFormatES2; + #endif }; FramebufferGLTest::FramebufferGLTest() { @@ -135,6 +140,16 @@ FramebufferGLTest::FramebufferGLTest() { &FramebufferGLTest::readBuffer, #endif &FramebufferGLTest::blit}); + + #ifdef MAGNUM_TARGET_GLES2 + if(Context::current()->isExtensionSupported()) { + rgbaFormatES2 = TextureFormat::RGBA8; + depthStencilFormatES2 = TextureFormat::Depth24Stencil8; + } else { + rgbaFormatES2 = TextureFormat::RGBA; + depthStencilFormatES2 = TextureFormat::DepthStencil; + } + #endif } void FramebufferGLTest::construct() { @@ -339,7 +354,7 @@ void FramebufferGLTest::attachTexture2D() { #ifndef MAGNUM_TARGET_GLES2 color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #else - color.setStorage(1, TextureFormat::RGBA, Vector2i(128)); + color.setStorage(1, rgbaFormatES2, Vector2i(128)); #endif MAGNUM_VERIFY_NO_ERROR(); @@ -356,12 +371,13 @@ void FramebufferGLTest::attachTexture2D() { Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); #endif + /** @todo Is there any better way to select proper sized/unsized format on ES2? */ Texture2D depthStencil; #ifndef MAGNUM_TARGET_GLES2 depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); #else - depthStencil.setStorage(1, TextureFormat::DepthStencil, Vector2i(128)); + depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128)); framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depthStencil, 0) .attachTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, 0); #endif @@ -394,7 +410,7 @@ void FramebufferGLTest::attachTexture3D() { #ifndef MAGNUM_TARGET_GLES2 color.setStorage(1, TextureFormat::RGBA8, Vector3i(128)); #else - color.setStorage(1, TextureFormat::RGBA4, Vector3i(128)); + color.setStorage(1, rgbaFormatES2, Vector3i(128)); #endif Framebuffer framebuffer({{}, Vector2i(128)}); @@ -490,7 +506,7 @@ void FramebufferGLTest::attachCubeMapTexture() { #ifndef MAGNUM_TARGET_GLES2 color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #else - color.setStorage(1, TextureFormat::RGBA, Vector2i(128)); + color.setStorage(1, rgbaFormatES2, Vector2i(128)); #endif framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapTexture::Coordinate::NegativeZ, 0); @@ -508,7 +524,7 @@ void FramebufferGLTest::attachCubeMapTexture() { depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); #else - depthStencil.setStorage(1, TextureFormat::DepthStencil, Vector2i(128)); + depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128)); framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0) .attachCubeMapTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); #endif @@ -562,14 +578,14 @@ void FramebufferGLTest::multipleColorOutputs() { #ifndef MAGNUM_TARGET_GLES2 color1.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #else - color1.setStorage(1, TextureFormat::RGBA, Vector2i(128)); + color1.setStorage(1, rgbaFormatES2, Vector2i(128)); #endif Texture2D color2; #ifndef MAGNUM_TARGET_GLES2 color2.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); #else - color2.setStorage(1, TextureFormat::RGBA, Vector2i(128)); + color2.setStorage(1, rgbaFormatES2, Vector2i(128)); #endif Renderbuffer depth; diff --git a/src/Magnum/Text/GlyphCache.cpp b/src/Magnum/Text/GlyphCache.cpp index 5568dc1f9..34115bee6 100644 --- a/src/Magnum/Text/GlyphCache.cpp +++ b/src/Magnum/Text/GlyphCache.cpp @@ -46,12 +46,15 @@ GlyphCache::GlyphCache(const Vector2i& originalSize, const Vector2i& size, const MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg); #endif - #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) + /** @todo Is there any better way to select proper sized/unsized format on ES2? */ + #ifndef MAGNUM_TARGET_GLES2 const TextureFormat internalFormat = TextureFormat::R8; #else - const TextureFormat internalFormat = - Context::current()->isExtensionSupported() ? - TextureFormat::Red : TextureFormat::Luminance; + TextureFormat internalFormat; + if(Context::current()->isExtensionSupported()) { + internalFormat = Context::current()->isExtensionSupported() ? + TextureFormat::R8 : TextureFormat::Red; + } else internalFormat = TextureFormat::Luminance; #endif initialize(internalFormat, size);