qnanopainter
qnanopainter copied to clipboard
Effective way to erase painting?
I'm trying to implement a eraser, clear subregion of the texture.
PageCanvas
is child of QNanoQuickItem
and render with QQuickFramebufferObject, what i do is binding the texture then glTexSubImage2D. But it crashs. So where is the right place(QNanoQuickItemPainter?) to do this operation, or i'm using the texture in a wrong way.
void PageCanvas::erase(int x, int y)
{
textureProvider()->texture()->bind();
const int eraserSize = 16;
quint32 subImage[eraserSize * eraserSize] = {};
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, eraserSize, eraserSize, GL_RGBA, GL_UNSIGNED_BYTE, subImage);
}