Skip to main content
gamedev.net
🔒 Locked

transparency, 2D

Started by gurumare 2 replies 550+ views
Original Post
gurumare
gurumare
Alright, here is a topic that has me banging my head against the wall. I have seen many snippets of code that uses primary and secondary buffers in conjunction with color keys to acheive transparency. I, however, am already rendering all of my sprites by using the pD3Ddevice->stretchRect(); In which I pass the source and destination RECT and the surface containing the image to be drawn. I have tried many different areas to find a place to set color keys or rendering states that would allow for sprite transparency. I am using directX 9.0 SDK and have a completely up to date system. Any ideas?
-=Blue Skiddo, We Can Too!!=-
Nik02
Nik02
StretchRect will only copy the source color (including alpha if present), it isn't supposed to blend the colors.

To draw "sprites", it is advisable to either: 1. use the ID3DXSprite interface or 2. Draw them manually by using two triangles to form rectangular areas, while the texture with the alpha channel is in use.

Color keys aren't supported in most hardware nowadays, nor can you set one during rendering. The D3DX image loaders handle color keys by turning the desired color to transparent black; it is your responsibility to use the correct alpha-related renderstates when rendering the images (textures).
Niko Suni
gurumare
gurumare
Can you tell me where to learn more about the sprite interface, or what renderstates to use to make this work?
-=Blue Skiddo, We Can Too!!=-
jollyjeffers
jollyjeffers
Quote:
Original post by gurumare
Can you tell me where to learn more about the sprite interface, or what renderstates to use to make this work?

All of the sprite stuff that Nik02 mentioned is covered in the SDK documentation [smile]

ID3DXSprite Interface

There isn't a specific sprite-only sample, but they do make an appearance across a large number of the Direct3D Samples, so you might want to look through them.

NeXe has an entry on the topic as well. Searching the forums also yields a large number of useful discussions.

If you have any specific questions about how to use them, feel free to post back and ask [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.