Jump to content
  • Advertisement


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


Alpha Blending, Transparency, Opacity, etc...

This topic is 5744 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 have a bitmap in a proprietary format that I am converting and loading into a DIRECT3DSURFACE8. Then I use D3DXLoadSurfaceFromSurface to load the image to the back surface, then present it, etc. This is all fine and dandy, the image shows up, I can drag it around, etc. However, I need to be able to overlay another image on top of it, and blend the new image with what''s already on the image surface with a certain alpha value. Is there any support in DirectX8 for doing this with bitmaps? I''ve been searching everywhere, but I''ve been unable to find anything about alpha blending except for textures and sprites. Does anyone have any ideas? Thanks for any help. Kelly

Share this post

Link to post
Share on other sites
Make sure these render flags are set.

p_Device->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
p_Device->SetRenderState(D3DRS_ALPHAREF, 0x01);


Then just change the Material's diffuse alpha # to show things transparent (I think the range is 0 - 1) just make it 0.5f to be 50% transparent.

I believe a Surface is the same as a Texture. Should be the same procedure between the two.

[edited by - Joeyblow2 on January 31, 2003 8:25:41 PM]

Share this post

Link to post
Share on other sites
Thanks for the reply. What do you mean when you say to change the materials diffuse alpha? If I have two images A and B, and I want B to be 50% translucent over A, what would I do? I''m guessing that I need .5f as the alpha channel for bitmap B, but how to I get B to appear over A? Thanks again for the reply.


Share this post

Link to post
Share on other sites
Let''s see now...

You''re using surface-to-surface code to present to the backbuffer rather than actual polygons. Right.

Well, if you were using polygons and texture steps, the method would be simple: Use two texture passes, set the blending render states correctly, set your second texture for the second pass.

Easy as pie.

As for a method to do it strictly in the surface, sorry I don''t think there are advanced functions available. I think it has to do with MS'' orientation with DirectX 8.1, which is more of a 3D approach with polygons than a 2D approach with surfaces.

You can still implement them yourselves, mind!

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

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!