Jump to content
  • Advertisement

Archived

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

Fourty_Two

Transparent Black?

This topic is 5572 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

Can some one explain to me the point of this? So I have a sprite with RGB(255,0,255) as the transparent area, and when I load the file with D3DXLoadSurfaceFromFile() and set the color key accordingly, the pixels are replaced with "transparent black" according to Microsoft. But there is nothing transparent about black... I can''t see a surface behind the "transparent" black. I have some functions that copy the image bit by bit and just ignore the RGB(255,0,255) pixels. These work fine, but I feel that they are slow and pointless. Is there something in the SDK that explains this? Or can one of you?

Share this post


Link to post
Share on other sites
Advertisement
try adding something like this before you render it


d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
d->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

d->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
d->SetRenderState( D3DRS_ALPHAREF, 0xFF00FFFF );
d->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );

d->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);


[edited by - Funkymunky on June 18, 2003 3:39:24 PM]

Share this post


Link to post
Share on other sites
That didn''t have any effect. Let me make sure I have the idea right.

1) I load my surface: D3DXLoadSurfaceFromSurface() and supply my color key, and DirectX sets it to black

2) In my Render() function: I add the above code in between my BeginScene() and EndScene() functions followed by D3DXLoadSurfaceFromSurface() which copies my surface to the backbuffer

Is that it?

Share this post


Link to post
Share on other sites
You wanna call D3DXLoadSurfaceFromFile in an initialization function, then display it in your rendering function, probably with CopyRects or something

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i don''t think either D3DXLoadSurfaceFromSurface or CopyRects goes through the rendering pipeline, so alpha tests, blending, and other render state settings won''t make a difference.

so if you''re trying to use D3DXLoadSurfaceFromSurface as a way to do transparent blits to the back buffer, i don''t think it''ll work.

what the docs are talking about is converting your fully opaque magic pink to a fully transparent black when it''s copied onto the destination surface. it is trsnsparent black since the transparency is kept in a separate alpha channel from the color channels. assuming of course that the destination surface supports alpha.

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!