Qt World Summit: Register Today!

Short question on QOpenGLWidget and framebuffer blit

  • Hi,
    I would like to develop an application with some OpenGL graphics.
    In my case there is no sense to write the whole Rendering code into the QOpenGLWidget, the Rendering should be done in several classes/objects but all of them can use the same QOpenGLContext as the QOpenGLWidget has. However they have to use a separate Framebuffer but the buffer can have the same size az my Widget. Here is the sort code I have tried, there is no other object just the "standard" QOpenGLWidget. And the code is in the paintGL function.

    QOpenGLFramebufferObjectFormat fboFormat;
     static QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(this->width(), this->height(),fboFormat);
     QOpenGLContext* context = this->context();
     QSurface *surf = context->surface();
     glClearColor(1.0f, 0.3f, 0.0f, 1.0f);
     QOpenGLFramebufferObject::blitFramebuffer(0, fbo, GL_COLOR_BUFFER_BIT, GL_NEAREST);

    However it draws nothing. I can convert the fbo to a QImage and save it or copy it to the Widget pixle-by-pixel. The new Background colour is there, but when I try to blit it, nothing happens.

    Can somebody please tell me how the makeCurrent() mechanism works?

    Thanks in advance :)

    [edit: Added missing coding tags: 3 ` before and after the code SGaist]