qnanopainter icon indicating copy to clipboard operation
qnanopainter copied to clipboard

Effective way to erase painting?

Open linuxaged opened this issue 5 years ago • 0 comments

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);
}

linuxaged avatar Dec 08 '18 06:12 linuxaged