Browse Source

Fix AbstractImage::pixelSize() for depth and stencil types.

Also make the assertion more descriptive and add "to sleep better" test.
This fixes the assertion failure in FramebufferGLTest.
pull/51/head
Vladimír Vondruš 13 years ago
parent
commit
2826345111
  1. 6
      src/AbstractImage.cpp
  2. 13
      src/Test/AbstractImageTest.cpp

6
src/AbstractImage.cpp

@ -97,6 +97,8 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) {
#ifdef MAGNUM_TARGET_GLES2
case ColorFormat::Luminance:
#endif
case ColorFormat::DepthComponent:
case ColorFormat::StencilIndex:
return 1*size;
case ColorFormat::RG:
#ifndef MAGNUM_TARGET_GLES2
@ -126,10 +128,8 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) {
return 4*size;
/* Handled above */
case ColorFormat::DepthComponent:
case ColorFormat::StencilIndex:
case ColorFormat::DepthStencil:
CORRADE_ASSERT_UNREACHABLE();
CORRADE_ASSERT(false, "AbstractImage::pixelSize(): invalid ColorType specified for depth/stencil ColorFormat", 0);
}
CORRADE_ASSERT_UNREACHABLE();

13
src/Test/AbstractImageTest.cpp

@ -34,15 +34,26 @@ class AbstractImageTest: public TestSuite::Tester {
public:
explicit AbstractImageTest();
void pixelSize();
void debugFormat();
void debugType();
};
AbstractImageTest::AbstractImageTest() {
addTests({&AbstractImageTest::debugFormat,
addTests({&AbstractImageTest::pixelSize,
&AbstractImageTest::debugFormat,
&AbstractImageTest::debugType});
}
void AbstractImageTest::pixelSize() {
CORRADE_COMPARE(AbstractImage::pixelSize(ColorFormat::RGBA, ColorType::UnsignedInt), 4*4);
CORRADE_COMPARE(AbstractImage::pixelSize(ColorFormat::DepthComponent, ColorType::UnsignedShort), 2);
CORRADE_COMPARE(AbstractImage::pixelSize(ColorFormat::StencilIndex, ColorType::UnsignedByte), 1);
CORRADE_COMPARE(AbstractImage::pixelSize(ColorFormat::DepthStencil, ColorType::UnsignedInt248), 4);
}
void AbstractImageTest::debugFormat() {
std::ostringstream o;
Debug(&o) << ColorFormat::RGBA;

Loading…
Cancel
Save