[SOLVED] clearing FrameBuffer



  • Hello

    i draw on a FBO with QPainter in an animation loop. The problem is i need to clear the FBO in every frame but this doesn't work. The only way to get it work is to use a background color like white, black or whatever but not with transparent.

    @
    // slot for QVariantAnimation signal valueChanged
    void updateValue(const QVariant &value) {
    //QGLFramebufferObject
    this->_fbo->bind();
    QPainter painter(this->_fbo);
    painter.setBackground(Qt::transparent);
    painter.eraseRect(this->boundingRect());
    painter.fillRect(0 + value.toInt(), 0, 100, 100, Qt::green);
    this->_fbo->release();
    this->update();
    }
    @
    The problem the FBO is not clear and so i get a large green rectangle instead of a nice moving one :) Any suggestions?



  • OK, i solved the problem. The magical part is this:

    @
    this->_fbo->bind();
    glClear(GL_COLOR_BUFFER_BIT);
    this->_fbo->release();
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.