How to enable alpha blending in DirectX?

How to do it in DirectX?

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); 

Somehow I just can't get it to work. Im using the code:

 d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR); d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); d3ddev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); d3ddev->SetRenderState(D3DRS_ALPHAREF, (DWORD)50); d3ddev->SetRenderState(D3DRS_ALPHATESTENABLE, 1); 

But this will make my polygon some kind of ghostly method, I can see all my polygons! I just want the texture with the alpha channel displayed through these fully transparent texture fragments. this works with alphatest, but it still shows black edges, so I think the blending is not turned on, although I set D3DRS_ALPHABLENDENABLE! What am I doing wrong?

+4
source share
1 answer

instead of SRCCOLOR I need to use SRCALPHA:

 d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 
+4
source

Source: https://habr.com/ru/post/1391012/


All Articles