void TextureGLTest::subImageBuffer() { 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), BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw)); MAGNUM_VERIFY_NO_ERROR(); BufferImage2D image(ColorFormat::RGBA, ColorType::UnsignedByte); texture.image(image, BufferUsage::StaticRead); const auto imageData = image.buffer().data<UnsignedByte>(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i(4)); 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); }
void TextureGLTest::invalidateSubImage() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; texture.setStorage(TextureFormat::RGBA8, Vector2i(32)); texture.invalidateSubImage(Vector2i(4), Vector2i(16)); MAGNUM_VERIFY_NO_ERROR(); }
void TextureGLTest::sampling() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; texture.setMinificationFilter(Sampler::Filter::Linear) .setMagnificationFilter(Sampler::Filter::Linear) .setWrapping(Sampler::Wrapping::ClampToBorder) .setBorderColor(Color3(0.5f)) .setMaxAnisotropy(Sampler::maxMaxAnisotropy()); MAGNUM_VERIFY_NO_ERROR(); }
void TextureGLTest::construct() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); { RectangleTexture texture; MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(texture.id() > 0); } MAGNUM_VERIFY_NO_ERROR(); }
void FramebufferGLTest::attachRectangleTexture() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::framebuffer_object>()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not available.")); RectangleTexture color; color.setStorage(TextureFormat::RGBA8, Vector2i(128)); RectangleTexture depthStencil; depthStencil.setStorage(TextureFormat::Depth24Stencil8, Vector2i(128)); Framebuffer framebuffer({{}, Vector2i(128)}); framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color, 0) .attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); }
void TextureGLTest::image() { if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); constexpr UnsignedByte data[] = { 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(2), data)); MAGNUM_VERIFY_NO_ERROR(); Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte); texture.image(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); }