Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Short question on QOpenGLWidget and framebuffer blit

    Game Development
    qopenglwidget qopenglcontext blit qopenglframebuf
    1
    1
    1167
    Loading More Posts
    • 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.
    • D
      DavidA last edited by SGaist

      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;
       fboFormat.setSamples(0);
       fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
       static QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(this->width(), this->height(),fboFormat);
       fbo->bind();
       QOpenGLContext* context = this->context();
       QSurface *surf = context->surface();
       context->makeCurrent(surf);
       painter.beginNativePainting();
       glClearColor(1.0f, 0.3f, 0.0f, 1.0f);
       glClear(GL_COLOR_BUFFER_BIT);
       painter.endNativePainting();
       fbo->release();
       makeCurrent();
       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]

      1 Reply Last reply Reply Quote 0
      • First post
        Last post