Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sammy70

D3DXLoadSurfaceFromSurface Colorkey?

This topic is 5965 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
(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.''

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!