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. After offscreen rendering the opengl texture is still empty
Qt 6.11 is out! See what's new in the release blog

After offscreen rendering the opengl texture is still empty

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 589 Views
  • 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.
  • K Offline
    K Offline
    K nard
    wrote on last edited by K nard
    #1

    Hello,

    I'm trying to render offscreen a qml file. But after the rendering the opengl texture remain empty.
    The test application can be found here but the render part look like that:

    _qcontext->makeCurrent(_offscreenSurface);
        _fbo->bind();
        _quickWindow->setRenderTarget(QQuickRenderTarget::fromOpenGLTexture(_fbo->texture(), GL_RGBA, QSize(_width, _height)));
        _renderControl->beginFrame();
        _renderControl->polishItems();
        _renderControl->sync();
        _renderControl->render();
        _renderControl->endFrame();
        _fbo->toImage().save(QString("toImgage-%1.png").arg(_fbo->texture()));
        _qcontext->functions()->glBindTexture(GL_TEXTURE_2D, _fbo->texture());
        QImage img(_width, _height, QImage::Format_RGBA8888);
        _qcontext->functions()->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, _width, _height, 0, GL_RGBA,  GL_UNSIGNED_INT_8_8_8_8_REV, img.bits());
        img.save(QString("img-%1.png").arg(_fbo->texture()));
    

    if the line 9th line ( _fbo->toImage() ) is commented out the texture remain empty. How can I force the result to be store in the texture without calling the toImage function ?

    Regards,

    1 Reply Last reply
    0
    • K Offline
      K Offline
      K nard
      wrote on last edited by
      #2

      I solved my issue by setting the graphic device to a device created from the opengl context and by creating the FBO while the opengl is binded.

      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