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(); void readBuffer();
#endif #endif
void blit(); void blit();
#ifdef MAGNUM_TARGET_GLES2
private:
TextureFormat rgbaFormatES2, depthStencilFormatES2;
#endif
}; };
FramebufferGLTest::FramebufferGLTest() { FramebufferGLTest::FramebufferGLTest() {
@ -135,6 +140,16 @@ FramebufferGLTest::FramebufferGLTest() {
&FramebufferGLTest::readBuffer, &FramebufferGLTest::readBuffer,
#endif #endif
&FramebufferGLTest::blit}); &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() { void FramebufferGLTest::construct() {
@ -339,7 +354,7 @@ void FramebufferGLTest::attachTexture2D() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); color.setStorage(1, TextureFormat::RGBA8, Vector2i(128));
#else #else
color.setStorage(1, TextureFormat::RGBA, Vector2i(128)); color.setStorage(1, rgbaFormatES2, Vector2i(128));
#endif #endif
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -356,12 +371,13 @@ void FramebufferGLTest::attachTexture2D() {
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string(); Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
#endif #endif
/** @todo Is there any better way to select proper sized/unsized format on ES2? */
Texture2D depthStencil; Texture2D depthStencil;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128));
framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
#else #else
depthStencil.setStorage(1, TextureFormat::DepthStencil, Vector2i(128)); depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128));
framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depthStencil, 0) framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depthStencil, 0)
.attachTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, 0); .attachTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, 0);
#endif #endif
@ -394,7 +410,7 @@ void FramebufferGLTest::attachTexture3D() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
color.setStorage(1, TextureFormat::RGBA8, Vector3i(128)); color.setStorage(1, TextureFormat::RGBA8, Vector3i(128));
#else #else
color.setStorage(1, TextureFormat::RGBA4, Vector3i(128)); color.setStorage(1, rgbaFormatES2, Vector3i(128));
#endif #endif
Framebuffer framebuffer({{}, Vector2i(128)}); Framebuffer framebuffer({{}, Vector2i(128)});
@ -490,7 +506,7 @@ void FramebufferGLTest::attachCubeMapTexture() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); color.setStorage(1, TextureFormat::RGBA8, Vector2i(128));
#else #else
color.setStorage(1, TextureFormat::RGBA, Vector2i(128)); color.setStorage(1, rgbaFormatES2, Vector2i(128));
#endif #endif
framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapTexture::Coordinate::NegativeZ, 0); framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapTexture::Coordinate::NegativeZ, 0);
@ -508,7 +524,7 @@ void FramebufferGLTest::attachCubeMapTexture() {
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128));
framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0);
#else #else
depthStencil.setStorage(1, TextureFormat::DepthStencil, Vector2i(128)); depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128));
framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0) framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0)
.attachCubeMapTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); .attachCubeMapTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0);
#endif #endif
@ -562,14 +578,14 @@ void FramebufferGLTest::multipleColorOutputs() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
color1.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); color1.setStorage(1, TextureFormat::RGBA8, Vector2i(128));
#else #else
color1.setStorage(1, TextureFormat::RGBA, Vector2i(128)); color1.setStorage(1, rgbaFormatES2, Vector2i(128));
#endif #endif
Texture2D color2; Texture2D color2;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
color2.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); color2.setStorage(1, TextureFormat::RGBA8, Vector2i(128));
#else #else
color2.setStorage(1, TextureFormat::RGBA, Vector2i(128)); color2.setStorage(1, rgbaFormatES2, Vector2i(128));
#endif #endif
Renderbuffer depth; 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); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg);
#endif #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; const TextureFormat internalFormat = TextureFormat::R8;
#else #else
const TextureFormat internalFormat = TextureFormat internalFormat;
Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>() ? if(Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>()) {
TextureFormat::Red : TextureFormat::Luminance; internalFormat = Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_storage>() ?
TextureFormat::R8 : TextureFormat::Red;
} else internalFormat = TextureFormat::Luminance;
#endif #endif
initialize(internalFormat, size); initialize(internalFormat, size);

Loading…
Cancel
Save