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. Short question on QOpenGLWidget
QtWS25 Last Chance

Short question on QOpenGLWidget

Scheduled Pinned Locked Moved General and Desktop
qopenglwidget fqopenglframebuf
1 Posts 1 Posters 624 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.
  • D Offline
    D Offline
    DavidA
    wrote on 18 Mar 2015, 11:04 last edited by DavidA
    #1

    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 :)

    1 Reply Last reply
    0

    1/1

    18 Mar 2015, 11:04

    • Login

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