From fc35adaac25373521f77ded1aa8fe4fc4ee0a63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 23 Jan 2014 20:17:58 +0100 Subject: [PATCH] Use *Image::dataSize() instead of manual buggy size computation. BufferImage test currently fails. --- src/Magnum/AbstractTexture.cpp | 4 ++-- src/Magnum/BufferImage.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index a60870426..5742d3e87 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -907,7 +907,7 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec #ifndef MAGNUM_TARGET_GLES template void AbstractTexture::image(GLenum target, GLint level, Image& image) { const Math::Vector size = DataHelper::imageSize(*this, target, level); - const std::size_t dataSize = size.product()*image.pixelSize(); + const std::size_t dataSize = image.dataSize(size); char* data = new char[dataSize]; (this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, data); image.setData(image.format(), image.type(), size, data); @@ -919,7 +919,7 @@ template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&); template void AbstractTexture::image(GLenum target, GLint level, BufferImage& image, BufferUsage usage) { const Math::Vector size = DataHelper::imageSize(*this, target, level); - const std::size_t dataSize = size.product()*image.pixelSize(); + const std::size_t dataSize = image.dataSize(size); if(image.size() != size) image.setData(image.format(), image.type(), size, nullptr, usage); diff --git a/src/Magnum/BufferImage.cpp b/src/Magnum/BufferImage.cpp index a02f4533f..08c6fb1ae 100644 --- a/src/Magnum/BufferImage.cpp +++ b/src/Magnum/BufferImage.cpp @@ -29,7 +29,7 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES2 template BufferImage::BufferImage(ColorFormat format, ColorType type, const typename DimensionTraits< Dimensions, Int >::VectorType& size, const void* data, BufferUsage usage): AbstractImage(format, type), _size(size), _buffer(Buffer::Target::PixelPack) { - _buffer.setData({data, pixelSize()*size.product()}, usage); + _buffer.setData({data, dataSize(size)}, usage); } template BufferImage::BufferImage(ColorFormat format, ColorType type): AbstractImage(format, type), _buffer(Buffer::Target::PixelPack) {} @@ -38,7 +38,7 @@ template void BufferImage::setData(ColorForm _format = format; _type = type; _size = size; - _buffer.setData({data, pixelSize()*size.product()}, usage); + _buffer.setData({data, dataSize(size)}, usage); } #ifndef DOXYGEN_GENERATING_OUTPUT