QGLFramebufferObject to QImage SLOW



  • Hi,

    I am working with QGLFramebufferObject and I use a QPainter into paintEvent() for showing the QGLFramebufferObject converted to QImage. All this render is SLOOOOOOOOOOW, I think is because I am doing a convertion of QGLFramebufferObject.toImage() into paintEvent(). How I can optimize this?.

    I attach the code:

    @GLclass::draw(){
    fbo->bind();
    glBegin(GL_POINTS);
    ...
    glEnd();
    fbo->release();
    }

    GLclass::paintEvent(){
    QPainter painter(this);
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    // SLOW convertion of fbo to QImage
    painter.drawImage(0, 0, fbo->toImage(),Qt::TransparentMode);
    }@

    Thanks beforehand,

    Fred



  • I'd try to separate the actual drawing on-screen from the generation of the pixmap you're drawing. So, see if you can move everything before your line 13 to some other method that doesn't get called every time you re-draw. And yes, going from the GL buffers back to main memory and then back to the video card is slow. You should just render the FBO as a texture directly.

    I am sorry, but I am not able to help you do the latter (I am not that familiar with OpenGL).



  • Thanks Andre,

    I am doing that you say. Trying to render the FBO as a texture but I can not get the texture display on the screen. I call updateGL() in a timer. can you give me a hand please?

    I replace GLclass::paintEvent() by GLclass::paintGL() as follow:

    @GLclass::draw(){
    fbo->bind();
    glBegin(GL_POINTS);
    ...
    glEnd();
    fbo->release();
    }

    GLclass::paintGL()
    {
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f);
    glClear( GL_COLOR_BUFFER_BIT );

    glPushMatrix();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-10, 10, -10, 10, -1, 1);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, fbo->texture());
    glTranslatef(0.0f,0.0f,0.0f);
    
    glBegin(GL_QUADS);
    {
        glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
        glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
        glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
        glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
    }
    glEnd();
    
    glDisable(GL_TEXTURE_2D);
    glPopMatrix();
    

    }
    @



  • Like I said:

    [quote author="Andre" date="1347004279"]
    I am sorry, but I am not able to help you do the latter (I am not that familiar with OpenGL). [/quote]

    Sorry!


Log in to reply
 

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