⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

How does QVideoFilterRunnable and OpenGL Context works together?

  • Greetings to everyone!

    I'm trying to program an augmented reality (AR) app with fading in 3D openGL objects on Android.

    Principle workflow:
    1.) The camera supplies a new videoframe (with openGL texture ID)
    2.) I capture this frame in QVideoFilterRunnable::run(...)
    3.) Then I make some object recognition and calculate the new position (inside the videoframe) where to fade in the 3D opengl object
    4.) Render the openGL object newly
    5.) Bring it in the openGL rendering pipeline (fixed function or compatibility profile) TOGETHER with the videoframe as a background texture (zero copy) to maximise the render speed

    Code example to manipulate the videoframe texture:

    QVideoFrame FilterRunnable::run(QVideoFrame* input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) {
         if(surfaceFormat.handleType() == QAbstractVideoBuffer::NoHandle) {
         } else {
            QOpenGLContext* c = QOpenGLContext::currentContext();
            QOpenGLFunctions* f = c->functions();
            GLuint textID = input->handle().toInt();
            float pixels[] = {
                0.0f, 0.0f, 0.0f,   1.0f, 1.0f, 0.0f,
                1.0f, 1.0f, 0.0f,   0.0f, 0.0f, 0.0f,
            f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
            f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_FLOAT, pixels);

    With glTexImage2D() the screen becomes black whithout any error.

    The problem is that I did't find any infos how FilterRunnable::run() handles the openGl context in the background. I don't know how using glDrawArrays(), glViewport() without the standard functions initializeGL(), resizeGL(), paintGL().

    For zero copying the fastest solution for my understanding would be to combine the videoframe (mapped on a background polygon) together with arbitrary openGl objects in front of it.

    Where I can get infos regarding this topic or what is the best way?

    Thxs in advance,


  • Hello PowerNow, I'm trying same. I found this tutorial link text, but I could not solve it.

    Did you find more information to recommend me?

Log in to reply