Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
Do you have any third-party rendering that could be changing the blend state? –  John Calsbeek Apr 5 '12 at 16:29
    
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 –  Indeera Apr 5 '12 at 17:00

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer

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

share|improve this answer
    
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))); –  Indeera Apr 5 '12 at 16:58
    
ColorFill replaces the pixels, no blending is performed. –  user15072 Apr 5 '12 at 18:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.