Advertisement

D3DXLoadSurfaceFromSurface Colorkey?

Started by March 18, 2002 05:26 PM
1 comment, last by Sammy70 22 years, 7 months ago
I''m trying to copy font chars from a bitmap loaded in a surface on top of my background image using the Dx8.1 function D3DXLoadSurfaceFromSurface(). Both surfaces are of the format D3DFMT_A8R8G8B8, SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ) is set. I tried all kind of Blending settings for SetRenderState, but none seemed to make any difference at all. My Problem is that the background of the source bitmap (the font) always shows, and I can''t get it to be transparent ... just either black or its original color (which is 0xFF00FF, aka magenta) Any idea what the blending for source and destination should be set to? (Or any other thing I should do to make this work) ??? Thanks, Sammy
After much searching and asking on the MSDN boards, it seems like the right way to do that is to set

g_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
g_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCALPHA);
g_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_INVSRCCOLOR);

Too bad it doesn''t seem that any blending options make any difference at all for D3DXLoadSurfaceFromSurface(). At least that''s what I must concur as the output is always the same, no matter what settings I''m using.

I guess I will really have to write my own pixelwise custom copy routine

Advertisement
(Rich from MSDN just answered my question, and I''m only putting it here for reference if someone have the same problem)

D3DXLoadSurfaceFromSurface doesn''t do any colorkeying as such. It really only copy rectangular blocks of data and does not care about Alphablending.

''To get them blended, you need to use the transparent image as a texture and draw textured triangles. Then RS Alpha Blend Enable, RS Src Blend and RS Dest Blend will control how the textured triangles are blended over the back buffer.''

This topic is closed to new replies.

Advertisement