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. Capturing the Headless Server image using QOpenGLFrameBufferObject
Forum Updated to NodeBB v4.3 + New Features

Capturing the Headless Server image using QOpenGLFrameBufferObject

Scheduled Pinned Locked Moved Unsolved General and Desktop
framebufferobje
3 Posts 2 Posters 299 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.
  • S Offline
    S Offline
    SyamRam
    wrote on 7 Sept 2021, 06:00 last edited by
    #1

    Hi,
    My application having multiple QGLWIdgets plotting in MainWindow. When am trying to capture Single QOPenFLWIdget image using
    m_fbo->toImage().convertToFormat(QImage::Format_RGB32);
    fb.save(ImageName, "PNG");
    but not able to capture all displayed QOPenGLWidgets which are plotting in mainwindow.
    My application have 10 OpenGLWidgets Plotting in sametime based on timestamp.

    Here am using One QOpenGLFrameBufferObject in mainwindow to capture multiple QOpenGLWidgets.

    mainwidnow.cpp

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

    QOpenGLContext openGLContext;
    openGLContext.setFormat(surfaceFormat);

    // QOpenGLContext::currentContext()->functions()->glFlush();

    openGLContext.create();
    if(!openGLContext.isValid()) return -1;

    QOffscreenSurface surface;
    surface.setFormat(surfaceFormat);
    surface.create();
    if(!surface.isValid()) return -2;

    openGLContext.makeCurrent(&surface);

    QOpenGLFunctions *f = openGLContext.currentContext()->functions();
    f->initializeOpenGLFunctions();
    

    // openGLContext.currentContext()->functions()->glFlush();
    f->glFlush();

    // QOpenGLFunctions_4_3_Core f;
    // if(!f->initializeOpenGLFunctions()) return -3;

    qDebug() << QString::fromLatin1((const char*)f->glGetString(GL_VERSION));

    QSize vpSize = QSize(100, 200);

    qDebug("Hi");

    QOpenGLFramebufferObjectFormat fboFormat;
    fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
    QOpenGLFramebufferObject fbo(vpSize, fboFormat);

    fboFormat.setTextureTarget(GL_TEXTURE_2D);

    fbo.bind();

    RenderAllOpenGLWidgets();

    QImage fb = fbo.toImage().convertToFormat(QImage::Format_RGB32);
    fb.save("image_file.png", "PNG");

    fbo.release();

    for(

    E 1 Reply Last reply 7 Sept 2021, 06:32
    0
    • S SyamRam
      7 Sept 2021, 06:00

      Hi,
      My application having multiple QGLWIdgets plotting in MainWindow. When am trying to capture Single QOPenFLWIdget image using
      m_fbo->toImage().convertToFormat(QImage::Format_RGB32);
      fb.save(ImageName, "PNG");
      but not able to capture all displayed QOPenGLWidgets which are plotting in mainwindow.
      My application have 10 OpenGLWidgets Plotting in sametime based on timestamp.

      Here am using One QOpenGLFrameBufferObject in mainwindow to capture multiple QOpenGLWidgets.

      mainwidnow.cpp

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

      QOpenGLContext openGLContext;
      openGLContext.setFormat(surfaceFormat);

      // QOpenGLContext::currentContext()->functions()->glFlush();

      openGLContext.create();
      if(!openGLContext.isValid()) return -1;

      QOffscreenSurface surface;
      surface.setFormat(surfaceFormat);
      surface.create();
      if(!surface.isValid()) return -2;

      openGLContext.makeCurrent(&surface);

      QOpenGLFunctions *f = openGLContext.currentContext()->functions();
      f->initializeOpenGLFunctions();
      

      // openGLContext.currentContext()->functions()->glFlush();
      f->glFlush();

      // QOpenGLFunctions_4_3_Core f;
      // if(!f->initializeOpenGLFunctions()) return -3;

      qDebug() << QString::fromLatin1((const char*)f->glGetString(GL_VERSION));

      QSize vpSize = QSize(100, 200);

      qDebug("Hi");

      QOpenGLFramebufferObjectFormat fboFormat;
      fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
      QOpenGLFramebufferObject fbo(vpSize, fboFormat);

      fboFormat.setTextureTarget(GL_TEXTURE_2D);

      fbo.bind();

      RenderAllOpenGLWidgets();

      QImage fb = fbo.toImage().convertToFormat(QImage::Format_RGB32);
      fb.save("image_file.png", "PNG");

      fbo.release();

      for(

      E Offline
      E Offline
      eyllanesc
      wrote on 7 Sept 2021, 06:32 last edited by eyllanesc 9 Jul 2021, 06:51
      #2

      @SyamRam please format your code using three tiks: ` before and after code

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SyamRam
        wrote on 7 Sept 2021, 06:50 last edited by
        #3

        "`"

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

        "`"

        1 Reply Last reply
        0

        1/3

        7 Sept 2021, 06:00

        • Login

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