Browse Source

Fixed test errors related to EXT_texture_storage on ES2.

pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
a13f8f3455
  1. 30
      src/Magnum/Test/FramebufferGLTest.cpp
  2. 11
      src/Magnum/Text/GlyphCache.cpp

30
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<Extensions::GL::EXT::texture_storage>()) {
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;

11
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<Extensions::GL::EXT::texture_rg>() ?
TextureFormat::Red : TextureFormat::Luminance;
TextureFormat internalFormat;
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>()) {
internalFormat = Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_storage>() ?
TextureFormat::R8 : TextureFormat::Red;
} else internalFormat = TextureFormat::Luminance;
#endif
initialize(internalFormat, size);

Loading…
Cancel
Save