Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGLFramebufferObject to QImage SLOW
Forum Updated to NodeBB v4.3 + New Features

QGLFramebufferObject to QImage SLOW

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fredQt
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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).

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fredQt
        wrote on last edited by
        #3

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

        }
        @

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved