TRANSPERANT SPRITES?
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?
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.
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.
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]
And although I'm the last person that should be complaining about forum etiquette, please don't quadruple-post [grin]
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
One problem though now when it begins to render the program crashes and doesn't tell me any problems
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement