void CubeMapTextureGLTest::subImage() { constexpr UnsignedByte zero[4*4*4] = {}; constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData)); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte); texture.image(CubeMapTexture::Coordinate::PositiveX, 0, image); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); CORRADE_COMPARE_AS(std::vector<UnsignedByte>(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector<UnsignedByte>{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), TestSuite::Compare::Container); #endif }
void TextureGLTest::subImage() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); constexpr UnsignedByte zero[4*4*4] = {}; constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; RectangleTexture texture; texture.setImage(TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero)); texture.setSubImage(Vector2i(1), ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData)); MAGNUM_VERIFY_NO_ERROR(); Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte); texture.image(image); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); CORRADE_COMPARE_AS(std::vector<UnsignedByte>(image.data(), image.data()+image.pixelSize()*image.size().product()), (std::vector<UnsignedByte>{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), TestSuite::Compare::Container); }
void CubeMapTextureGLTest::subImage() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data)); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte}); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); CORRADE_COMPARE_AS( Containers::ArrayReference<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()), Containers::ArrayReference<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container); #endif }
void CubeMapTextureGLTest::subImageBuffer() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero)); texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead); const auto imageData = image.buffer().data<UnsignedByte>(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); CORRADE_COMPARE_AS(imageData, Containers::ArrayReference<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container); #endif }
void CubeMapTextureGLTest::generateMipmap() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::PositiveY, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::PositiveZ, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::NegativeX, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::NegativeY, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); texture.setImage(CubeMapTexture::Coordinate::NegativeZ, 0, TextureFormat::RGBA8, ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32))); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(texture.imageSize(0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(1), Vector2i( 0)); #endif texture.generateMipmap(); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(texture.imageSize(0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(1), Vector2i(16)); CORRADE_COMPARE(texture.imageSize(2), Vector2i( 8)); CORRADE_COMPARE(texture.imageSize(3), Vector2i( 4)); CORRADE_COMPARE(texture.imageSize(4), Vector2i( 2)); CORRADE_COMPARE(texture.imageSize(5), Vector2i( 1)); MAGNUM_VERIFY_NO_ERROR(); #endif }