Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Share image with DirectX in graphics card



  • I need to show html webpage texture in a D3D based application.

    Current solution is to use QWebView to load the html, then render to QImage, and finally copy to D3D texture bit by bit. Below is the sample code, which is very slow due to the data transportation cost between CPU and graphics card. Is there anyway to let D3D directly use the Qt generated image in graphics card?

    [code]
    void QtEngine::LoadTexture(LPDIRECT3DTEXTURE9 pTexture) {
    QPainter p(image);
    page()->mainFrame()->render(&p);
    D3DLOCKED_RECT lr;
    pTexture->LockRect(0, &lr, NULL, 0);
    int ppl = lr.Pitch / 4;
    uint *tex_data = (uint *)lr.pBits;
    for (int y = 0; y < image->height(); ++y) {
    uint *s = (uint *)image->scanLine(y);
    memcpy(tex_data + ppl * y, s, lr.Pitch);
    }
    pTexture->UnlockRect(0);
    }
    [/code]


Log in to reply