CanvasImage: fix updating after fillRect / setPixel

This commit is contained in:
James Turner 2020-04-18 21:31:16 +01:00
parent b72553f6f0
commit f144bd5a89

View File

@ -871,6 +871,10 @@ SGRect<int> intersectRect(const SGRect<int>& a, const SGRect<int>& b)
image = _texture->getImage(); image = _texture->getImage();
} }
if (image->getDataVariance() != osg::Object::DYNAMIC) {
image->setDataVariance(osg::Object::DYNAMIC);
}
const auto format = image->getInternalTextureFormat(); const auto format = image->getInternalTextureFormat();
auto clippedRect = intersectRect(rect, SGRect<int>(0, 0, image->s(), image->t())); auto clippedRect = intersectRect(rect, SGRect<int>(0, 0, image->s(), image->t()));
@ -917,6 +921,8 @@ SGRect<int> intersectRect(const SGRect<int>& a, const SGRect<int>& b)
} }
image->dirty(); image->dirty();
auto c = getCanvas().lock();
c->enableRendering(true); // force a repaint
} }
void Image::setPixel(int x, int y, const std::string& c) void Image::setPixel(int x, int y, const std::string& c)
@ -935,8 +941,14 @@ SGRect<int> intersectRect(const SGRect<int>& a, const SGRect<int>& b)
allocateImage(); allocateImage();
image = _texture->getImage(); image = _texture->getImage();
} }
if (image->getDataVariance() != osg::Object::DYNAMIC) {
image->setDataVariance(osg::Object::DYNAMIC);
}
image->setColor(color, x, y); image->setColor(color, x, y);
auto c = getCanvas().lock();
c->enableRendering(true); // force a repaint
} }
void Image::allocateImage() void Image::allocateImage()