TRANSPERANT SPRITES?

Started by
8 comments, last by busyme 18 years, 7 months ago
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?
Advertisement
I tried loading the files that can hold data for transperancy but no luck.
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.
ok gonna try it
my compiler screams illegal call of non-static member function
whats happening
then if placed in global it says redeclaration is not allowed
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]
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
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.

This topic is closed to new replies.

Advertisement