DX9 StretchRect to Texture Fails

| | August 4, 2015

Alright, I got the code almost working to copy memory data to a texture, process it with DirectX9 into another texture and copy the result back to memory. Almost all the errors are gone and the code compiles and runs. However, this line fails.

HR(m_pDevice->StretchRect(m_pOffsceenSurface, NULL, m_pTextureSurface, &rect, D3DTEXF_LINEAR));

In this source file, in function Present()


Additionally, if I comment out StretchRect, ColorFill doesn’t fail but doesn’t appear to be taking effect when reading the memory back (CopyFromBuffer returns a black frame).

HR(m_pDevice->ColorFill(m_pTextureSurface, NULL, D3DCOLOR_ARGB(0xFF, 200, 200, 200)));

First I call Initialize with a dummy HWND, which calls CreateResources and CreateRenderTarget, which sets my render target

return m_pDevice->SetRenderTarget(0, m_pTextureSurface);

Then I call CreateVideoSurface, and finally I can ProcessFrame for each video frame. The code isn’t crashing except StretchRect, but isn’t working either.

Any idea?

Leave a Reply