Skip to content

QtWS: Super Early Bird Tickets Available!

  • 0 Votes
    2 Posts
    2k Views
    NeoswN

    I have find a way to get a QImage of an QWindow:
    Make a standard QWindow with is surface and add the following code:

    // set the current context OpenGL // check if an OpenGlContext is created QOpenGLContext context; context.setFormat(format()); if (!context.create()) qFatal("Cannot create the requested OpenGL context!"); context.makeCurrent(this); // init a new framebuffer QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); fboFormat.setMipmap(true); fboFormat.setSamples(4); fboFormat.setTextureTarget(GL_TEXTURE_2D); fboFormat.setInternalTextureFormat(GL_RGB); resize(this->width(), this->height()); const QRect drawRect(0, 0, this->width(), this->height()); const QSize drawRectSize = drawRect.size(); _fbo = new QOpenGLFramebufferObject(drawRectSize, fboFormat); _fbo->bind(); ... _fboImage = new QImage(_fbo->toImage(false));

    But, this is work only if the window is "visible", when it is set to Hidden the rendering of Qt3D was made (the rendering loop, because the GPU is used and the FPS is divided by 3), but the QOpenGLFramebufferObject was not filled :/

    Do you have any idea of how force the filling of the fbo ?

    PS: I have found this here : http://stackoverflow.com/questions/17221730/do-offscreen-renderopengl-with-qt5

  • 0 Votes
    3 Posts
    4k Views
    SightlineS

    I have followed your solution but still have the same problem. I am binding the defaultFrameBufferObject() accessed via the shared context in my rendering class but it's still not drawing on-screen. Could you please update the code to include your implementation of the binding operation?