void CubeMapTextureGLTest::subImageBuffer() { 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), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES BufferImage2D image(ColorFormat::RGBA, ColorType::UnsignedByte); texture.image(CubeMapTexture::Coordinate::PositiveX, 0, image, BufferUsage::StaticRead); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); const auto imageData = image.buffer().data<UnsignedByte>(); CORRADE_COMPARE_AS(std::vector<UnsignedByte>(imageData.begin(), imageData.end()), (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 CubeMapTextureGLTest::imageBuffer() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, 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(2)); CORRADE_COMPARE_AS(imageData, Containers::ArrayReference<const UnsignedByte>{Data}, TestSuite::Compare::Container); #endif }
void CubeMapTextureGLTest::imageFullBuffer() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2}) .setSubImage(0, {}, BufferImage3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, DataFull, BufferUsage::StaticDraw}); MAGNUM_VERIFY_NO_ERROR(); BufferImage3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); const auto imageData = image.buffer().data<UnsignedByte>(); CORRADE_COMPARE_AS(imageData, Containers::ArrayReference<const UnsignedByte>{DataFull}, TestSuite::Compare::Container); }
void CubeMapTextureGLTest::image() { CubeMapTexture texture; texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, 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(2)); CORRADE_COMPARE_AS( Containers::ArrayReference<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()), Containers::ArrayReference<const UnsignedByte>{Data}, TestSuite::Compare::Container); #endif }
void CubeMapTextureGLTest::imageFull() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::direct_state_access>()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); CubeMapTexture texture; texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2, 2}) .setSubImage(0, {}, ImageReference3D{ColorFormat::RGBA, ColorType::UnsignedByte, Vector3i{2, 2, 6}, DataFull}); MAGNUM_VERIFY_NO_ERROR(); Image3D image = texture.image(0, {ColorFormat::RGBA, ColorType::UnsignedByte}); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6)); CORRADE_COMPARE_AS( Containers::ArrayReference<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()), Containers::ArrayReference<const UnsignedByte>{DataFull}, TestSuite::Compare::Container); }
void CubeMapTextureGLTest::image() { constexpr UnsignedByte data[] = { 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(2), data)); 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(2)); CORRADE_COMPARE_AS(std::vector<UnsignedByte>(image.data(), image.data()+image.pixelSize()*image.size().product()), std::vector<UnsignedByte>(data, data+16), TestSuite::Compare::Container); #endif }