1
\$\begingroup\$

I have a surface (OffScreenPlain or RenderTarget with D3DFMT_A8R8G8B8) which I copy pixels (ARGB) to, from a third party function. Before pixel copying, Bits are accessed by LockRect.

This surface is then StretchRect to the Backbuffer which is (D3DFMT_A8R8G8B8). Surface and Backbuffer are different dimensions. Filtering is set to D3DTEXF_NONE.

Just after creating the d3d device I've set following RenderState settings

D3DRS_ALPHABLENDENABLE -> TRUE
D3DRS_BLENDOP          -> D3DBLENDOP_ADD
D3DRS_SRCBLEND         -> D3DBLEND_SRCALPHA
D3DRS_DESTBLEND        -> D3DBLEND_INVSRCALPHA

But I see no alpha blending happening. I've verified that alpha is specified in pixels.

I've done a simple test by creating a vertex buffer and drawing a triangle (DrawPrimitive) which displays with alpha blending.

In this test surface was StretchRect first and then DrawPrimitive, and the surface content displays without alpha blending and the triangle displays with alpha blending.

What am I missing here? Thanks

EDIT: I must add this is on x64 Win7

\$\endgroup\$
2
  • \$\begingroup\$ Do you have any third-party rendering that could be changing the blend state? \$\endgroup\$ Commented Apr 5, 2012 at 16:29
  • \$\begingroup\$ I've created a simple project without any third party stuff where I create a OffScreenPlain buffer, lock it and put some pixels with alpha and StretchRect to back buffer. But the results are the same \$\endgroup\$
    – Indy9000
    Commented Apr 5, 2012 at 17:00

2 Answers 2

1
\$\begingroup\$

StretchRect doesn't perform blending. You'd need to actually render a quad that's mapped with your surface texture in order to get blending to happen.

\$\endgroup\$
0
\$\begingroup\$

It seems the alpha information is being lost at some point. Try inspecting the surface pixels between each operation to find out where.

\$\endgroup\$
2
  • \$\begingroup\$ I have tried a color fill to the backbuffer itself without any other operations, but the results are the same m_pDevice->ColorFill(m_pBackBuffer,NULL,D3DCOLOR_ARGB(0x10,0,0,0xFF))); \$\endgroup\$
    – Indy9000
    Commented Apr 5, 2012 at 16:58
  • \$\begingroup\$ ColorFill replaces the pixels, no blending is performed. \$\endgroup\$
    – user15072
    Commented Apr 5, 2012 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .