Skip to content
  • 0 Votes
    3 Posts
    225 Views
    S

    "`"

    QSurfaceFormat surfaceFormat;
    surfaceFormat.setMajorVersion(4);
    surfaceFormat.setMinorVersion(3);

    QOpenGLContext openGLContext;
    openGLContext.setFormat(surfaceFormat);
    openGLContext.create();

    QOffscreenSurface surface;
    surface.setFormat(surfaceFormat);
    surface.create();

    openGLContext.makeCurrent(&surface);
    QOpenGLFunctions *f = openGLContext.currentContext()->functions();
    f->initializeOpenGLFunctions();
    f->glFlush();

    QSize vpSize = QSize(m_ScreenWidth, m_ScreenHeight);

    qDebug("Hi");

    QOpenGLFramebufferObjectFormat fboFormat;
    fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);

    m_fbo = new QOpenGLFramebufferObject (vpSize, fboFormat);
    fboFormat.setTextureTarget(GL_TEXTURE_2D);

    RenderAllOPenGLWidgets(); // reendering all widgets based on timestamp.

    this->update();
    QCoreApplication::processEvents();
    QThread::usleep(1000);

    m_fbo->release();

    QString ImageName = QString::number(FBOCaptureTime) + QString(".png");;
    QImage fb = m_fbo->toImage().convertToFormat(QImage::Format_RGB32);
    fb.save(ImageName, "PNG");

    "`"

  • 0 Votes
    4 Posts
    993 Views
    W

    Off the top of my head, I am not sure if fbo::save() is valid while the FBO is still bound as the target for drawing. Try releasing it first and then calling save. An FBO can only be used as a texture when it is not bound as a target -- I think that applies to all readback operations.

    Also, you have a glClearColor, but you never glClear(). If there is garbage in the depth buffer of the FBO, maybe your stuff is never getting drawn. glClear() the depth buffer and the image buffer before you draw. At very least you should be able to see the clear color in the FBO when you save it, so you know the binding is working at that point.

  • 0 Votes
    2 Posts
    985 Views
    p3c0P

    Hi @gs_chris It looks very close to the warning here.

    Warning: Resizing a framebuffer object is a costly operation, avoid using the QQuickPaintedItem::FramebufferObject render target if the item gets resized often.

  • 0 Votes
    1 Posts
    539 Views
    No one has replied