Qt Forum

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

    Unsolved QOpenGLContext used in multithread

    General and Desktop
    qopenglcontext multithread
    1
    1
    738
    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.
    • nashge
      nashge last edited by

      Hi,guys.I met a problem. I used QGraphicsView to display 3D animation by integration with OpenSceneGraph.Meanwhile i capture QGraphicsView's image to generate a video file.

      In main thread i use (dynamic_cast<QOpenGLWidget *>(m_pGraphicsView->viewport()))->context()->functions()->glReadPixels() ,it can work,but the animation will be nonfluency.

      So I create another thread to capture QGraphicsView's image to generate a video file.So i pass m_pGraphicsView to thread,and use same code.But in this thread i can't capture image, :(.

      I find somebody says the problem is QOpenGLContext can't be used in another thread,they use QOpenGLContext->moveToThread,etc. I don't understand well.

      Can any one help me? I list my code snippet:

      void CMainWindow::recordView()
      {

         m_pAVIGenerator = new FFMPEG(m_pGraphicsView);
         m_pAVIGenerator->SetupVideo(filePath, 1480, 920, 25, 10, 40000000);
         m_pAVIGenerator->start();
          //m_pAVIGenerator is my another thread
      

      }

      void FFMPEG::run()
      {

      while (!mNeedStop)
      {
      	QImage image(1480, 920, QImage::Format_RGB888);
      	(dynamic_cast<QOpenGLWidget *>(m_pView->viewport()))->context()->functions()->glReadPixels(192, 0, 1480, 920, GL_RGB, GL_UNSIGNED_BYTE, image.bits());
                  ..........
      	WriteFrame((char *)image.bits());
      }
      

      }

      How can i change these code?Thanks for your patient read my problem!

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