Rendering QImage on QGLWidget of QML plugin

后端 未结 2 807
情深已故
情深已故 2021-01-06 07:17

I\'m trying to write a QML plugin that reads frames from a video (using a custom widget to do that task, NOT QtMultimedia/Phonon), and each frame is convert

相关标签:
2条回答
  • 2021-01-06 07:33

    Solved. The problem was that I was trying to create a new GL context within my plugin when I should be retrieving the GL context from the application that loaded it.

    This code was very helpful to understand how to accomplish that.

    By the way, I discovered that the stuff was being draw inside view. It's just that I needed to execute view->show(), but that created another window which was not what I was looking for. The link I shared above has the answer.

    0 讨论(0)
  • 2021-01-06 07:43

    I think that you have to draw on your glwidget using the opengl functions.

    One possible way is to override your paintGL() method in GLWidget and then draw your image with glDrawPixels().

    glClear(GL_COLOR_BUFFER_BIT);
    glDrawPixels(buffer.width(), buffer.height(), GL_RGBA, GL_UNSIGNED_BYTE, buffer.bits());
    

    Where buffer is a QImage object that needs to be converted using QGLWidget::converrtToGLFormat() static method.

    Look at this source for reference: https://github.com/nayyden/ZVector/blob/master/src/GLDebugBufferWidget.cpp

    0 讨论(0)
提交回复
热议问题