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. QOpenGLContext used in multithread

QOpenGLContext used in multithread

Scheduled Pinned Locked Moved Unsolved General and Desktop
qopenglcontextmultithread
1 Posts 1 Posters 1.1k 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.
  • nashgeN Offline
    nashgeN Offline
    nashge
    wrote on last edited by
    #1

    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
    0

    • Login

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