From f144bd5a8911a37c55e7c9621db202fff32ca1cf Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 18 Apr 2020 21:31:16 +0100 Subject: [PATCH] CanvasImage: fix updating after fillRect / setPixel --- simgear/canvas/elements/CanvasImage.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simgear/canvas/elements/CanvasImage.cxx b/simgear/canvas/elements/CanvasImage.cxx index 09e09edf..ed4f24d8 100644 --- a/simgear/canvas/elements/CanvasImage.cxx +++ b/simgear/canvas/elements/CanvasImage.cxx @@ -871,6 +871,10 @@ SGRect intersectRect(const SGRect& a, const SGRect& b) image = _texture->getImage(); } + if (image->getDataVariance() != osg::Object::DYNAMIC) { + image->setDataVariance(osg::Object::DYNAMIC); + } + const auto format = image->getInternalTextureFormat(); auto clippedRect = intersectRect(rect, SGRect(0, 0, image->s(), image->t())); @@ -917,6 +921,8 @@ SGRect intersectRect(const SGRect& a, const SGRect& b) } image->dirty(); + auto c = getCanvas().lock(); + c->enableRendering(true); // force a repaint } void Image::setPixel(int x, int y, const std::string& c) @@ -935,8 +941,14 @@ SGRect intersectRect(const SGRect& a, const SGRect& b) allocateImage(); image = _texture->getImage(); } + + if (image->getDataVariance() != osg::Object::DYNAMIC) { + image->setDataVariance(osg::Object::DYNAMIC); + } image->setColor(color, x, y); + auto c = getCanvas().lock(); + c->enableRendering(true); // force a repaint } void Image::allocateImage()