Jump to content
  • Advertisement
Sign in to follow this  
busyme

TRANSPERANT SPRITES?

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

How do you load transperant sprites in directX and make it understand it. So far i loaded regular sprite and everything works well, until I tried to load trasperant sprite. It wouldn't load or it still would be with white background. What am I doing wrong here?

Share this post


Link to post
Share on other sites
Advertisement
Hi there busyme,
How are you doing buddy?

The Problem
Loading Transparent sprites and using them.

The Solution
When you load the sprite you need to tell direct3d that it must blend the sprite.
1) When drawing the sprite set the flags to alphablend
2) enable alphablending for the device
c++
IDirect3DDevice9::SetRenderState( D3DRS_ALPHABLENDENABLE, true );
C#
Device.RenderState.AlphaBlendEnable = true;
3) Make sure that your other renderstates are correct for other rendering.
i.e. device.RenderState.SourceBlend = Blend.SourceColor; (Default)
device.RenderState.DestinationBlend = Blend.InvSourceAlpha; (Default)

I hope this helps a bit. Take care.

Share this post


Link to post
Share on other sites
You took Armadon's post too literally. You have a IDirect3DDevice9 pointer, correct? Use it like this: yourD3DDevicePointer->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
And although I'm the last person that should be complaining about forum etiquette, please don't quadruple-post [grin]

Share this post


Link to post
Share on other sites
I got that passed long time ago, :) sorry i figured it out.

One problem though now when it begins to render the program crashes and doesn't tell me any problems

Share this post


Link to post
Share on other sites
pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);

its in my initDirect3D function.

it points to that line and just doesn't say anything.


then i placed it in my render function hooray it compiles and no crashes. Only this time my png files are still opaque, no transparency.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!