From 98df39d9c280d5c32611636f851c4e9766547301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 7 Jan 2014 16:15:10 +0100 Subject: [PATCH] Use *Image::dataSize() in Framebuffer::read(). Fixes Framebuffer test when ARB_robustness is used (without ARB_robustness it was overwriting memory and could lead to weird behavior). --- src/AbstractFramebuffer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/AbstractFramebuffer.cpp b/src/AbstractFramebuffer.cpp index aceb75896..2c0d67627 100644 --- a/src/AbstractFramebuffer.cpp +++ b/src/AbstractFramebuffer.cpp @@ -194,7 +194,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Ima #else bindInternal(readTarget); #endif - const std::size_t dataSize = image.pixelSize()*size.product(); + const std::size_t dataSize = image.dataSize(size); char* const data = new char[dataSize]; readImplementation(offset, size, image.format(), image.type(), dataSize, data); image.setData(image.format(), image.type(), size, data); @@ -213,8 +213,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf image.setData(image.format(), image.type(), size, nullptr, usage); image.buffer().bind(Buffer::Target::PixelPack); - /** @todo De-duplicate buffer size computation */ - readImplementation(offset, size, image.format(), image.type(), image.pixelSize()*size.product(), nullptr); + readImplementation(offset, size, image.format(), image.type(), image.dataSize(size), nullptr); } #endif