Add Canvas::Image.dirtyPixels()

This commit is contained in:
James Turner 2020-04-28 09:36:29 +01:00
parent 57b0f70a55
commit ad3621e23b
2 changed files with 15 additions and 2 deletions

View File

@ -947,10 +947,18 @@ SGRect<int> intersectRect(const SGRect<int>& a, const SGRect<int>& b)
} }
image->setColor(color, x, y); image->setColor(color, x, y);
auto c = getCanvas().lock();
c->enableRendering(true); // force a repaint
} }
void Image::dirtyPixels()
{
osg::ref_ptr<osg::Image> image = _texture->getImage();
if (!image)
return;
image->dirty();
auto c = getCanvas().lock();
c->enableRendering(true); // force a repaint
}
void Image::allocateImage() void Image::allocateImage()
{ {
osg::Image* image = new osg::Image; osg::Image* image = new osg::Image;

View File

@ -115,6 +115,11 @@ namespace canvas
void setPixel(int x, int y, const osg::Vec4& color); void setPixel(int x, int y, const osg::Vec4& color);
/**
* mark the image pixels as modified, so the canvas is re-painted
*/
void dirtyPixels();
osg::ref_ptr<osg::Image> getImage() const; osg::ref_ptr<osg::Image> getImage() const;
// void setRow(int row, int offset, ) // void setRow(int row, int offset, )