QQuickView, QQuickWindow, QOpenGLFramebufferObject

  • Hello,

    I'm would like to access the QQuickView framebuffer image just afterRendering.

    I can add a new QopenGLFramebuuferObject using the AfterRendering slot but it' not what I want.

    I would like to export the current QQuickView framebuffer (or access it if possible) to change e.g. the pixels positions.

    I tested to add a custom buffer to avoid using the default one but I can't find the way using setRenderTarget.

    May you please advise me ?


  • Looks likes I'm directly with the framebuffer.

    Attempting to use the this->renderTarget()->toImage() crash but simply reading the buffer I can have is as in qopenglframebufferobject.cpp

    QImage img(width(), height(),QImage::Format_RGB32);
    glReadPixels(0,0, width(),height(),GL_BGRA, GL_UNSIGNED_BYTE, img.bits());

    I was not expecting this way, still have something to understand.

  • Do not use:


    Have a look at this post "here.":http://qt-project.org/forums/viewthread/27117/

  • Thank you, this way I think that you grab the window if I'm right.

    My final plan is to modify the image prior it's sent to the display driver.

    The point I need more to understand now would be ho to corretly specify an other framebuffer than the default one.

  • Yes you are right however this action is a big performance hit and should be run in a separate thread if possible.

    I haven't tried this myself but have a look at this "QQuickWindow::setRenderTarget":http://qt-project.org/doc/qt-5.0/qtquick/qquickwindow.html#setRenderTarget. This allows you to set your own custom fbo as the render target for a specific window.

    I'm sure you have already thought about this but what about using shaders to achieve pixel/fragment manipulation before rendering?

  • Thank you, I look for AfterRendering and the shader manipulation can only be done BeforeRendering if I'm right.

    My problem is indeed in the correct use the the setRenderTarget.
    If you have a working code sampling I would be glad.

  • Ah, yes of course my mistake. Shaders are applied before the final output. But if you want to change the positions of pixels then a pixel shader comes in real handy.

    As I've said before I have not played around with setRenderTarget but will give it a go when I have more time. What problems are you facing with this by the way?

  • I don't find the correct way to change the QQuickView default framebuffer to an new explicit one.

Log in to reply

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