Important: Please read the 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?

    void QtEngine::LoadTexture(LPDIRECT3DTEXTURE9 pTexture) {
    QPainter p(image);
    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);

Log in to reply